Difference between revisions of "Pandora - Sample - Update Multiple Level 2 Records Associated with a Level 1"
From SmartWiki
Line 33: | Line 33: | ||
==Notes== | ==Notes== | ||
* When updating date fields (both standard fields and custom fields) using Pandora the format must be '''yyyy-mm-dd''' | * When updating date fields (both standard fields and custom fields) using Pandora the format must be '''yyyy-mm-dd''' | ||
+ | |||
+ | ==See Also== | ||
+ | * [[Updating Dates with Pandora]] | ||
[[Category:Pandora]] | [[Category:Pandora]] |
Revision as of 17:05, 5 August 2010
The following script finds all Level 2 records associated with the current Level 1 record that are at given statuses.
It then updates the enddate standard field on each of the found Level 2 records with the current date.
//=================================================================== //This function updates the enddate standard field on all approved level 2 activities //=================================================================== function SetEndDate(){ ss_developer_key="12345abcdefghijkomnop123455676889="; var appid=54321; //the application ID of the UTA var today="@year(currentdate)@-@month(currentdate)@-@day(currentdate)@"; var filter="objectid='@opportunityid@' and statusid in (12360,12361,12363)"; //this performs the search and returns all matching records in variable "rs" rs=level23_find(false ,'',appid,2,'eventid,enddate',filter); //now loop through every record contained in "rs": for (i=1;i<=rs.recordcount;i++){ eid=rs.getfieldbyname(i,'eventid'); //save the eventid of the current Level 2 var rset=new ssRecordSet(null); //create a new blank record set (rset) rset.addfieldnames("eventid,enddate"); //define the fields to be updated var idx=rset.getnewrecnumber(); //create new record rset.addfieldvaluebyname(idx,'eventid',eid); //update event id with the one from the current record in "rs" rset.addfieldvaluebyname(idx,'enddate',today); //update the enddate with today's date var nrs=level23_update(false ,'',102717,2,rset); //update the Level 2 activity in the database //the updated Level 2 record is stored in variable "nrs" which could be used further if necessary... } }
Notes
- When updating date fields (both standard fields and custom fields) using Pandora the format must be yyyy-mm-dd