Changes

Pandora - Update Contact (One Record)

599 bytes added, 09:25, 2 April 2014
m
Example: - added further example, to append new role to user
rset.addfieldvaluebyname(idx,"email","email@email.fake");
==ExampleExamples==This will add update the role with ID 12345, to the contact with ID 9876543.
<pre>ss_developer_key="@system.dev_key@";
var rs=new ssRecordSet(null);
rs.addfieldvaluebyname(idx,'userid',9876543);
rs.addfieldvaluebyname(idx,'rolelist',',12345,');
var rsnew=contact_update(false,"",rs,false);</pre>
 
This will append the role with ID 56789, to the contact with ID 9876543.
<pre>ss_developer_key="@system.dev_key@";
// get users existing rolelist
filter='userid=9876543';
var rs= contact_find(false ,"","rolelist",filter,"",0,1);
var roles = rs.getfieldbyname(1,"rolelist");
// append new role
roles += "56789,";
 
// now update the user with the new rolelist
var rs=new ssRecordSet(null);
rs.addfieldnames("userid,rolelist");
idx=rs.getnewrecnumber();
rs.addfieldvaluebyname(idx,'userid',9876543);
rs.addfieldvaluebyname(idx,'rolelist',roles);
var rsnew=contact_update(false,"",rs,false);</pre>
[[Category: Pandora]]
0
edits