Pandora - Sample - Update Fields on UTA Record
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
Contents
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
updatefields("cf_1742399",frm.cf_1742399.value);
or
updatefields("assigned","@me.userid@");