Changes

Created page with 'The following script finds all Level 2 records associated with the current Level 1 record that are at given statuses. Then and updates the '''enddate''' standard field with the cā€¦'
The following script finds all Level 2 records associated with the current Level 1 record that are at given statuses. Then and updates the '''enddate''' standard field with the current date on each.


<pre>
//===================================================================
//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...
}
}
</pre>

==Notes==
* When updating date fields (both standard fields and custom fields) using Pandora the format must be '''yyyy-mm-dd'''


[[Category:Pandora]]
0
edits