Difference between revisions of "Pandora - Sample - Update Fields on UTA Record"

From SmartWiki
Jump to: navigation, search
 
Line 41: Line 41:
 
   rset.addfieldvaluebyname(idx,fieldname,fielddata);
 
   rset.addfieldvaluebyname(idx,fieldname,fielddata);
 
   var rs=level23_update(false ,"",appid,2,rset);
 
   var rs=level23_update(false ,"",appid,2,rset);
 +
}
 
</PRE>
 
</PRE>
 
For Level 3 replace the last line with:
 
For Level 3 replace the last line with:

Latest revision as of 17:32, 9 March 2014

Sample Code - Updating Fields on a UTA Record

The following function can be used to update a given field to the database without actually saving the page.

This can be useful when triggering a workflow using a script, if the given field value is required in the workflow e-mail (for example) if the script will trigger the workflow prior to the record being saved. It can also be useful for a field that is not visible or editable to the user viewing the record that needs to be updated in certain circumstances.

Pandora Function

Level 1

This function updates the database with the field(s) passed so that the new data is saved to the server when workflows are triggered by the scripts on this page.

function updatefields(fieldname,fielddata){
ss_developer_key="123456-yFNRjOyOB1234567890tPobcei4ZPcX5sYeeys52g=";
   var appid='123456';         //the application ID of the relevant UTA
   var addfields="opportunityid,"+fieldname;
   var rset=new ssRecordSet(null);
   rset.addfieldnames(addfields);
   var idx=rset.getnewrecnumber();
   rset.addfieldvaluebyname(idx,'opportunityid','@opportunityid@');
   rset.addfieldvaluebyname(idx,fieldname,fielddata);
   var rs=levelone_update(false ,"",appid,rset);
}


Level 2

This function updates the database with the field(s) passed so that the new data is saved to the server when workflows are triggered by the scripts on this page.

function updatefields(fieldname,fielddata){
ss_developer_key="12345-lasdhaldkvhj”;
   var appid='123456';         //the application ID of the relevant UTA
   var addfields="eventid,"+fieldname;
   var rset=new ssRecordSet(null);
   rset.addfieldnames(addfields);
   var idx=rset.getnewrecnumber();
   rset.addfieldvaluebyname(idx,'eventid','@eventid@');
   rset.addfieldvaluebyname(idx,fieldname,fielddata);
   var rs=level23_update(false ,"",appid,2,rset);
}

For Level 3 replace the last line with:

var rs=level23_update(false ,"",appid,3,rset); 


Using the Function

Examples:

  • To update a custom field:
updatefields("cf_1742399",frm.cf_1742399.value);
Note that frm must have been defined on the page
  • To update the assigned standard field (Level 2 or Level 3)
updatefields("assigned","@me.userid@");

Notes