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>
 +
For level 3 replace the last line with:
 +
var rs=level23_update(false ,'',appid,3,rset);
  
for level 3 use: level23_update(false ,'',appid,3,rset);
 
}</PRE>
 
  
  
=Sample calls to the function from another script=
+
=Using the Function=
  
 
updatefields("cf_1742399",frm.cf_1742399.value);
 
updatefields("cf_1742399",frm.cf_1742399.value);
Line 53: Line 54:
 
    
 
    
 
updatefields("assigned","@me.userid@");
 
updatefields("assigned","@me.userid@");
 +
 +
  
 
[[Category: Pandora]]
 
[[Category: Pandora]]

Revision as of 13:38, 19 August 2010

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

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

or

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