Pandora - Sample - Update Fields on UTA Record

From SmartWiki
Revision as of 11:05, 23 July 2010 by sharris@smartsimple.com (talk | contribs) (Created page with '==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 usefu…')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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="424623-yFNRjOyOB0275ID9wdlPJtPobcei4ZPcX5sYeeys52g=";
   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 use: level23_update(false ,'',appid,3,rset); 
}


Sample calls to the function from another script

updatefields("cf_1742399",frm.cf_1742399.value);

or

updatefields("assigned","@me.userid@");