0

I have a custom conga sign button that sends out the contract, but we want a validation rule on the button so that the user cannot send the contract until all of the fields have been populated.

Essentially a validation rule on the button that would show an error and not allow the user to go to the next page.

How would I go about doing that? Here is the existing custom button:

   /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=
2

A validation rule won't help here. Those are best used for DML operations (insert/edit) to ensure criteria are met. "All fields" is too wide of criteria to be used in a validation rule.

Instead, have you considered making most/all of the fields for the object required on the layout? This would solve your problem without really requiring much change.

Another solution would be to add a workflow rule, which sets a custom field (called Ready_To_Send_Contract__c or something), when a certain number of fields have values in them. You could do this with a trigger, based on a status value, or via admin process (approval processes or manual editing), all that matters is you have some method of saying "Yes, this is ready" that can be used as a field.

Create a custom button, but not a link button - a javascript button. Inside the button, you'll need an if statement, shown below. We switch in this if based on the value of the Ready_To_Send_Contract__c field.

if ({!RecordType.Ready_To_Send_Contract__c}) {
   window.open(...); // Link will need to be javascript safe 
} else {
   alert('This record is not ready to have a contract sent! You need to do x first.');
}

Now, since we have a conditional field we can use, we can control the behavior of a button based on that field. We could check all the fields in the button (or check specific fields), but thats slow. I'd rather defer those checks to an async process, and keep the fields used out of code.

I think the hardest parts for you will be identifying exactly what fields you need to require/check, and then get your link "javascript safe" in order to use it in the button.

  • Thanks for your reply :) I tried to use a validation rule in the button as we want the user to be able t save and go back to edit the record before pressing send. Essentially the user would fill in some fields, save then come back to the record later, then press send which is where they would receive the error message if they have not filled in the appropriate boxes (not all of them). – Natasha Ali Jul 5 '18 at 12:08
  • A validation rule won't fire in this context. They only fire on DML operations (update, insert). Try a workflow rule which sets some flag field to true or false depending if the record meets your criteria. Use that field in a on-click javascript button to control the button. – battery.cord Jul 9 '18 at 13:25

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.