Skip to content

Instantly share code, notes, and snippets.

@nicksambrato
Last active September 23, 2016 00:29
Show Gist options
  • Save nicksambrato/228712434dcfb8227415d85b1b55307e to your computer and use it in GitHub Desktop.
Save nicksambrato/228712434dcfb8227415d85b1b55307e to your computer and use it in GitHub Desktop.
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
//Before conga runs it makes Create_Client_Approval__c != null
var updateClientApproval = new Array();
//search for ID & create client approval from the order that is the child of this //opportunity we're in now
var result = sforce.connection.query("SELECT Id, Create_Client_Approval__c FROM Order__c where Opportunity__c = '{!Opportunity__c.Id}' ");
//take those results and make an array called records
var records = result.getArray("records");
//for is a loop: for ([initialExpression]; [condition]; [incrementExpression])
// start at zero ; if zero is less than the records in the array ; then go through //records in internals of 1
for (i = 0; i < records.length ; i++)
{
var child = result.records[i] ;
var value = child.Create_Client_Approval__c ;
//var value = result.records[i].Create_Client_Approval__c ;
if (!value) value = null ;
child.Create_Client_Approval__c = true ;
updateClientApproval.push(child);
}
result = sforce.connection.update(updateClientApproval);
var CongaURL = "https://composer.congamerge.com" +
"?sessionId={!API.Session_ID}" +
"&serverUrl={!API.Partner_Server_URL_290}" +
"&id={!Opportunity__c.Id}" +
"&reportID=[Orders]00O50000004d8K1,[Account]00O50000004d8KB,[Contact]00O50000004d8Mv,[Approvals]00O50000004d9W8,[Fulfillments]00O50000004d9XQ,[Runs]00O50000004d4Rh" +
"&defaultpdf=1" +
"&templateID={!IF(CONTAINS( Opportunity__c.Convert_Payment_Terms_From_Picklist__c ,"Net"),"a0P50000006w30k","a0P50000006w31n")}" +
"&emailtemplateID={!IF(CONTAINS( Opportunity__c.Convert_Payment_Terms_From_Picklist__c ,"Net"),"a0G5000000D4jIM", "a0G5000000D4jIR")}" +
"&emailrelatedtoID={!Opportunity__c.Id}" +
"&emailtoID={!Opportunity__c.ContactId__c}" +
"&LG2=2" +
"&LG4=1" +
"&LG7=Followup+on+Ballpark+{!Opportunity__c.Account__c}+{!Opportunity__c.Name}" +
"&BML=Approval+Is+Being+Generated" +
"&ofn=Options+{!Opportunity__c.Name}" +
"&ds7=2" +
"&UF0=1" ;
window.open( CongaURL, "Conga", "width=700,height=550,menubar=0" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment