Populating Auto Number Custom Fields with Pandora

From SmartWiki
Jump to: navigation, search

When updating an Auto Number custom field using Pandora you have 2 options:

  1. Populate the actual value with Pandora
  2. Prompt the SmartSimple server to assign the value based on the next value configured on the Auto Number custom field setting.


For the first option, the values are added directly by the javascript code, just like any other custom field that stores data. To update custom field with ID 1234713 with number "7500" the following code would be used:

                rset=new ssRecordSet(null);
                rset.addfieldnames("eventid,cf_1234713");
                var idx=rset.getnewrecnumber();
 
                rset.addfieldvaluebyname(idx,'eventid',eventid);
                rset.addfieldvaluebyname(idx,'cf_1234713',"7500");
     
                result=level23_update(false ,"",100022,2,rset);


For the second option you add the letter "a" in front of the fieldid. The value that you pass will be ignored, and the system will process the variables in the configuration of the Auto Number custom field to determine what value will be stored.

For example:

                rset=new ssRecordSet(null);
                rset.addfieldnames("eventid,cf_a1234713");
                var idx=rset.getnewrecnumber();   
 
                rset.addfieldvaluebyname(idx,'eventid',eventid);
                rset.addfieldvaluebyname(idx,'cf_a1234713','ignore');
     
                result=level23_update(false ,"",100022,2,rset);


Important

  • Prefixing the custom field id with the letter "a" is only appropriate if the custom field is an Auto Number field.


See Also