0

I have a CongaSign button that sends a contract when clicked, but I need it to show an error or alert if the user hasn't filled in certain fields. I tried itenter code here with JS too but because of the curly brackets {} being needed by the conga button, it didn't work. What are the alternatives to this (especially in lightning) Here is the button with the JS:

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} . 
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}

if({!(ISBLANK(Contract.Functional_Skills__c),
ISBLANK(Contract.All_Smart_Targets_met__c),
ISBLANK(Contract.Additional_Support__c),
ISBLANK(Contract.App_Attendance_Absent__c),
ISBLANK(Contract.App_Attendance_Late__c),
ISBLANK(Contract.App_Attendance_Present__c),
ISBLANK(Contract.App_Attendance_Present_including_Late2__c),
ISBLANK(Contract.How_can_you_improve_your_score__c),
ISBLANK(Contract.Apprentice__c),
ISBLANK(Contract.Apprentice_of_the_month__c),
ISBLANK(Contract.Apprenticeship_work__c),
ISBLANK(Contract.At_risk_record_to_be_created_or_updated__c),
ISBLANK(Contract.Career_Options__c),
ISBLANK(Contract.Competency__c),
ISBLANK(Contract.Date_of_last_Review__c),
ISBLANK(Contract.Date_of_next_Review__c),     
ISBLANK(Contract.Date_of_next_Review__c,
ISBLANK(Contract.Do_we_need_to_open_FS_aims__c),
ISBLANK(Contract.Due_Date_1__c),
ISBLANK(Contract.Due_Date_2__c),
ISBLANK(Contract.Due_Date_3__c),
ISBLANK(Contract.Due_Date_4_),
ISBLANK(Contract.Employer_Representative_Comments__c),
ISBLANK(Contract.English_Diagnostic_Assessment__c),
ISBLANK(Contract.Enrichment_sessions__c),
ISBLANK(Contract.For_Whom__c),
ISBLANK(Contract.For_Whom_2__c),
ISBLANK(Contract.For_Whom_3__c),
ISBLANK(Contract.For_Whom_4__c),
ISBLANK(Contract.Functional_Skills__c),
ISBLANK(Contract.Health_Safety_E_D_topic__c),
ISBLANK(Contract.How_woul_you_score_yourself__c),
ISBLANK(Contract.Is_employer_partnerships_input_required__c),
ISBLANK(Contract.Issues_or_Concerns__c),
ISBLANK(Contract.Is_the_manager_happy_generally__c),
ISBLANK(Contract.LDS_Comments__c),
ISBLANK(Contract.LDS_How_to_improve_score_next_month__c),
ISBLANK(Contract.Maths_English__c),
ISBLANK(Contract.Maths_Diagnostic_Assessment__c),
ISBLANK(Contract.Overall_Progress_Blue__c),
ISBLANK(Contract.Overall_Progress_Green__c),
ISBLANK(Contract.Overall_Progress_Orange__c),
ISBLANK(Contract.PDP__c),
ISBLANK(Contract.Projects_or_areas_of_work__c),
ISBLANK(Contract.Qualification_Level__c),
ISBLANK(Contract.Reflective_log__c),
ISBLANK(Contract.Review_Location__c),
ISBLANK(Contract.Safeguarding_topic__c),
ISBLANK(Contract.Score_for_the_month__c),
ISBLANK(Contract.LDS_Score_for_the_month__c),
ISBLANK(Contract.Target_1__c),
ISBLANK(Contract.Target_2__c),
ISBLANK(Contract.Target_3__c),
ISBLANK(Contract.Target_4__c),
ISBLANK(Contract.Target_Type_1__c),
ISBLANK(Contract.Target_Type_2__c),
ISBLANK(Contract.Target_Type_3__c),
ISBLANK(Contract.Target_Type_4__c),
ISBLANK(Contract.The_Employer_Reference__c),
ISBLANK(Contract.To_keep_myself_and_others_safe_I_can__c),
ISBLANK(Contract.Upcoming__c),
ISBLANK(Contract.Work_Attendance_Late__c),
ISBLANK(Contract.Work_Attendance_Sick__c))}
){
alert("Please ensure you have filled all of the required fields before 
sending this review.");
}
else{
window.open(/apex/APXTConga4__Conga_Composer?SolMgr=1
&serverUrl={!API.Partner_Server_URL_370} 
&Id={!Contract.Id} 
&Queryid=a0d0O00000CrPWw?pv0={!Contract.AccountId} 
&CSRoutingType=SERIAL 
&CSRecipient1={!User.Id} 
&QVar0Id=a0d0O00000CrtuO?pv0={!Contract.AccountId} 
&CSRecipient2={QVar0} 
&Qvar1Id=a0d0O00000CruVo?pv0={!Contract.AccountId} 
&CSRecipient3={Qvar1} 
&csRequestReminder=1 
&csRecipient4=005200000053EM3 
&csrole4=CC 
&OFN={!Account.FirstName}+{!Account.LastName}+Progress+Review+{!Today} 

&CSEmailSubject=Please+sign+{!Account.FirstName}+ {!Account.LastName}’s+progress+review {!Today} 

&csEmailMessage=Hi+{!Account.Line_Manager_First_Name__c}, 

Thank you for taking the time to contribute to{!Account.FirstName}’s review today. {!Account.FirstName}’s reviews are a requirement of the funding for the apprenticeship, so please take the time to look over it and sign it as soon as possible. 
We aim to have all reviews signed by all parties within 48 hours of the review taking place. Please don’t hesitate to get in touch with {!Account.FirstName}’s LDS, {!Account.LDS__c} if you have any questions. Yours sincerely, LDN Group 


&TemplateId=a0l0O00000YxONv 
&csvisible=1 &DefaultPDF=1;
}
2
  1. You need to wrap your URL in strings - otherwise its going to cause syntax errors, making the button fail to run.
  2. You need to use AND in your button to output a boolean value, just putting a bunch of ISBLANK's next to each other will cause some funky output (I'd expect something like if(FALSEFALSEFALSE){} which isn't a boolean and won't run right)
  3. More of an opinion than anything else, but I still feel like thats too many fields to control something like this - it just adds complexity. Reducing the number of fields used by the code is important - you don't want this failing whenever you change or remove a field, and adding to a long field list gets difficult whenever you need to add new fields. Even reducing these down to grouped formula fields would be more useful (especially considering you have multiple similar fields, such as Due_Date_1__c, Due_Date_2__c, etc.)

Creating a formula named, Has_Due_Dates__c, which would look like this:

NOT(AND(ISBLANK(Due_Date_1__c), ISBLANK(Due_Date_2__c), ISBLANK(Due_Date_3__c), ISBLANK(Due_Date_4__c)))

You can then use this field & others instead of your grouped fields. This would be helpful in the conga url parameters mentioned by @Plug as well.

Having the named field lets you provide more useful information (Such as a message saying "You are missing a due date") to your users (which when you have a ton of fields, all required, but not until you try an action) clarity on what that user needs to do in order to send a quote is important.

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}

// move to var keep code clean
// Add either formula fields, field set by workflow, or just all those fields into a valid AND statement 
// AND Should return valid boolean for variables use  
var ready = {!NOT(AND(IBLANK(Contract.All_Smart_Targets_met__c), ISBLANK(Contract.App_Attendance_Absent__c), ISBLANK(Contract.App_Attendance_Late__c)))}; 

if(!ready){
    // Cant use multiline strings w/o correct syntax - dont break strings 
    alert("Please ensure you have filled all of the required fields before sending this review.");
} else {
    // Move to var to keep code clean 
    // Create a string 
    var congaUrl = '/apex/APXTConga4__Conga_Composer?SolMgr=1'; 

    // Add to our existing string 
    congaUrl += '&serverUrl={!API.Partner_Server_URL_370}';
    congaUrl += '&Id={!Contract.Id}';
    congaUrl += '&Queryid=a0d0O00000CrPWw?pv0={!Contract.AccountId}';
    // ... The rest of the parameters .. 
    congaUrl += '&CSEmailSubject=Please+sign+{!Account.FirstName}+ {!Account.LastName}’s+progress+review {!Today}';
    congaUrl += '&TemplateId=a0l0O00000YxONv';
    // For multiline strings, you need to use \n as a newline character, since you can't actually break the string, that would cause a syntax problem
    congaUrl += '&csEmailMessage=Hi+{!Account.Line_Manager_First_Name__c},\nThank you for taking the time to contribute to{!Account.FirstName}’s review today. {!Account.FirstName}’s reviews are a requirement of the funding for the apprenticeship, so please take the time to look over it and sign it as soon as possible.\nWe aim to have all reviews signed by all parties within 48 hours of the review taking place. Please don’t hesitate to get in touch with {!Account.FirstName}’s LDS, {!Account.LDS__c} if you have any questions.\nYours sincerely, LDN Group';
    congaUrl += '&csvisible=1&DefaultPDF=1';

    window.open(congaUrl);
}

You can also use the AND(..) formula above to set the parameters given by @Plug.

1

You can try using &DC and &DCL Conga control parameters

Retrieved from: Conga Blog

DC stands for “disable Conga.” Now, why would you want to do that? Let’s say you don’t want your users to be able to send out quotes if they gave the customer a large discount. You can use DC to tell Conga “when a user clicks the Quote button, make sure the field discount doesn’t exceed 18%. If it does exceed 18%, don’t let the user generate the quote.” If certain criteria are not met, DC allows you to automatically shut off the Conga button.

When the value of the DC parameter is 1 Composer won’t run, and when the value is 0 Composer will run. However, you wouldn’t want DC to always equal 1 because then no one would be able to use Composer. Therefore, the value of the DC parameter is typically determined by an “IF statement” structure, meaning that whether DC equals 0 or 1 is dependent on what the IF statement returns. An example would be DC={!IF(Opportunity.StageName = “Closed Won”, “0”, “1”) }. That parameter value is a bit frightening, so let’s break it down. In this example, if the Opportunity Stage is “Closed Won,” then DC=0, and Composer will be enabled. If the Opportunity Stage is anything other than “Closed Won,” then DC=1 and Composer will be disabled.

Some links to get you started:

DC Conga Parameter Guide

DCL Conga Parameter Guide

Usage Example using IF Statement

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.