Set field default on new record with JavaScript variable. This example returns

Set field default on new record with JavaScript variable. This example returns

bbrindzabbrindza Posts: 222Questions: 53Answers: 1

How can I set the default field value using a JavaScript variable on a new records.

fields: [ 
                {
                  label: "Location Code:",
                  name: "NWFF.MTSYS.MSLOC",
                  type:'readonly', 
                  attr:{ disabled:true },  
                  default: {userLocationCode; },    
                 }, 
                 {
                   label: "System Code:",
                   name: "NWFF.MTSYS.MSCODE"
                 }, 
                 {
                   label: "Description:",
                   name: "NWFF.MTSYS.MSDESC"
                },
                {
                   label: "Date of Last PM:",
                   name: "NWFF.MTSYS.MSMLDT"
                  }, 
                 {
                    label: "Days to Next PM:",
                    name: "NWFF.MTSYS.MSDAYS"
                  }
        ]

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 57,236Questions: 1Answers: 9,113 Site admin
    edited May 11 Answer ✓

    Hi Bob,

    Use field.def as a function. That way the function will be evaluated when the default value is required.

    edit - Example

    def: function () { return userLocationCode; }
    

    Or if userLocationCode is static and won't change over the life time of the page:

    def: userLocationCode
    

    Allan

  • bbrindzabbrindza Posts: 222Questions: 53Answers: 1

    Thank you Allan. That is what I needed

Sign In or Register to comment.