Difference between revisions of "Pandora - Update Contact (One Record)"

From SmartWiki
Jump to: navigation, search
m (Example: - added further example, to append new role to user)
 
(10 intermediate revisions by 2 users not shown)
Line 24: Line 24:
 
==Notes==
 
==Notes==
  
Loginfornew = true to enable user access.
+
* Loginfornew = true to initiate a user session for this contact when creating a new user.
 
+
* Rolelist = "2345,5665"
Rolelist = "234,566"
+
* Usertype = 10=User (default), 30=Local User Administrator, 50=Global User Administrator
 
+
* active: 0=No access, 1=Administration or Portal Interface, 3=User Centric or Applicant Interface
Usertype = 10, 30, 50
+
* CompanyID needs to be set
 
+
* IsExternal: 1=External, 0=Internal - driven by company ID
Isactive = 0, 1 admin, 3 user centric or applicant
+
* sendpassword: including '''sendpassword''' with value "1" will trigger the new user password e-mail (you must also include the email address in the recordset):
 +
  rset.addfieldvaluebyname(idx,"active",1);
 +
  rset.addfieldvaluebyname(idx,"sendpassword",1);
 +
  rset.addfieldvaluebyname(idx,"email","email@email.fake");
  
CompanyID needs to be set
+
==Examples==
 +
This will 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.addfieldnames("userid,rolelist");
 +
idx=rs.getnewrecnumber();
 +
rs.addfieldvaluebyname(idx,'userid',9876543);
 +
rs.addfieldvaluebyname(idx,'rolelist',',12345,');
 +
var rsnew=contact_update(false,"",rs,false);</pre>
  
IsExternal = 1 or 0 (Internal) - driven by company ID
+
This will append the role with ID 56789, to the contact with ID 9876543.
 
+
<pre>ss_developer_key="@system.dev_key@";
sendpassword = 1  - will trigger the new user password e-mail (you must also include the email address in the recordset):
+
// get users existing rolelist
  rset.addfieldvaluebyname(idx,"sendpassword","1");
+
filter='userid=9876543';
  rset.addfieldvaluebyname(idx,"email","email@email.fake");
+
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]]
 
[[Category: Pandora]]

Latest revision as of 05:25, 2 April 2014

This function will update a single user record or create a new user record.

contact_update(flag,callbackfunc,rset,loginfornew)
Parameter Description
Flag Asynchronous processing Flag

Set to False for synchronous processing.

Set to True for asynchronous processing.

Callbackfunc User created Java function to manage the callback from an asynchronous function.
rset ssRecordSet object containing data to be updated to the system.
loginfornew Set to true to enable user access.
Returns

Notes

  • Loginfornew = true to initiate a user session for this contact when creating a new user.
  • Rolelist = "2345,5665"
  • Usertype = 10=User (default), 30=Local User Administrator, 50=Global User Administrator
  • active: 0=No access, 1=Administration or Portal Interface, 3=User Centric or Applicant Interface
  • CompanyID needs to be set
  • IsExternal: 1=External, 0=Internal - driven by company ID
  • sendpassword: including sendpassword with value "1" will trigger the new user password e-mail (you must also include the email address in the recordset):
  rset.addfieldvaluebyname(idx,"active",1);
  rset.addfieldvaluebyname(idx,"sendpassword",1);
  rset.addfieldvaluebyname(idx,"email","email@email.fake");

Examples

This will update the role with ID 12345, to the contact with ID 9876543.

ss_developer_key="@system.dev_key@";
var rs=new ssRecordSet(null);
rs.addfieldnames("userid,rolelist");
idx=rs.getnewrecnumber();
rs.addfieldvaluebyname(idx,'userid',9876543);
rs.addfieldvaluebyname(idx,'rolelist',',12345,');
var rsnew=contact_update(false,"",rs,false);

This will append the role with ID 56789, to the contact with ID 9876543.

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);