Editing - Auto populate custom fields

4632
5
Jump to solution
02-04-2015 08:12 PM
RichardMoussopo
Occasional Contributor III

I am trying to auto populate the custom fields in the editor but no luck.

here is what I thought would work by assigning the value to the textBox but nothing...

   
var someValue = "My value";
var myTextBox = new dijit.form.TextBox({
        id: "firstname",
        value: someValue 
       
          });
          
          var txtEmail = new dijit.form.TextBox({
        id: "email",
        value: "my email here" 
       
          });
       
        var layerInfos = [{
          'featureLayer':featureLayer,
          'showAttachments':false,
          'showDeleteButton':true,
          'fieldInfos':[
            {'fieldName':'name','label':'Name','customField': myTextBox},
            {'fieldName':'email','label':'Email','customField': txtEmail}
          ]
        }]; 
0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor

If you want to set default values for new features you can do this using the feature layer's before-apply-edits event.  If you set the default values there they will appear when the popup attribute window displays for new features.  Here's an example:

        requestLayer.on("before-apply-edits", function(g){

            var features = g.adds;

            for(i = 0; i < features.length; i++){

              var f = features;

              f.attributes.name = "Jane Doe";

            }

        });

View solution in original post

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus

Richard,

   Have you tried to set the value after you create the textbox?

myTextBox.set('value', 'somevalue');

0 Kudos
RichardMoussopo
Occasional Contributor III

Hi Robert,

yes I did try that still no luck. the image bellow shows the fields that need to be auto filled.

autofill.PNG

0 Kudos
KellyHutchins
Esri Frequent Contributor

If you want to set default values for new features you can do this using the feature layer's before-apply-edits event.  If you set the default values there they will appear when the popup attribute window displays for new features.  Here's an example:

        requestLayer.on("before-apply-edits", function(g){

            var features = g.adds;

            for(i = 0; i < features.length; i++){

              var f = features;

              f.attributes.name = "Jane Doe";

            }

        });

0 Kudos
RichardMoussopo
Occasional Contributor III

Thank you Kelly,

you saved my day !

captureField.PNG

0 Kudos
LindaDunklee
New Contributor III

I've been successful in modifying this code to update fields based on edited fields - however, when you change the driving field after the initial input, it does not update the dependent fields.  I believe this has something to do with the "before-apply-edits" but haven't been able to get anything else to work.  Kelly, do you have anything that would allow autopopulation that dynamically?

Thanks!

0 Kudos