You need to sign in to do that
Don't have an account?
Shawn Kaiser 7
How to have validation rule fire on button?
New to coding:
I have the below code being used on a button to fire a process builder. I need add a rule to make sure prior to the process builder being fired that the following field on the contact record "Termination__c" is not blank.
If blank a message should appear = termation date is required AND the process builder does NOT fire until this termination date is filled in:
Current javascript in the button:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
//Select the current contact records and put it into the record //variable
var records = sforce.connection.query("SELECT Id, Offboarding_Process_Builder_Trigger__c FROM Contact Where id = '{!Contact.Id}'");
//Pull the contact object out of the records variable and set it to //contactRec
var contactRec = records.getArray('records')[0];
//Increase contactRec Offboarding_Process_Builder_Trigger__c
//JS sees the number field as a string so this will make sure that //is a number - Number(contactRec.Offboarding_Process_Builder_Trigger__c)
contactRec.Offboarding_Process_Builder_Trigger__c = Number(contactRec.Offboarding_Process_Builder_Trigger__c) + 1;
//Update contactRec object
sforce.connection.update([contactRec]);
//Reload the page
window.location.reload();
I thought I could insert the below somewhere in the above to make it work?
//Termination field is requied when selecting the termination button
var contactReq = "{!Contact.Termination__c}";
if(contactReq != '') ;
else {
alert('Termination Date is required');
I have the below code being used on a button to fire a process builder. I need add a rule to make sure prior to the process builder being fired that the following field on the contact record "Termination__c" is not blank.
If blank a message should appear = termation date is required AND the process builder does NOT fire until this termination date is filled in:
Current javascript in the button:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
//Select the current contact records and put it into the record //variable
var records = sforce.connection.query("SELECT Id, Offboarding_Process_Builder_Trigger__c FROM Contact Where id = '{!Contact.Id}'");
//Pull the contact object out of the records variable and set it to //contactRec
var contactRec = records.getArray('records')[0];
//Increase contactRec Offboarding_Process_Builder_Trigger__c
//JS sees the number field as a string so this will make sure that //is a number - Number(contactRec.Offboarding_Process_Builder_Trigger__c)
contactRec.Offboarding_Process_Builder_Trigger__c = Number(contactRec.Offboarding_Process_Builder_Trigger__c) + 1;
//Update contactRec object
sforce.connection.update([contactRec]);
//Reload the page
window.location.reload();
I thought I could insert the below somewhere in the above to make it work?
//Termination field is requied when selecting the termination button
var contactReq = "{!Contact.Termination__c}";
if(contactReq != '') ;
else {
alert('Termination Date is required');
So, Glyn - #1 does not work, #2 I changes == true to == null but still does not work and the last #1 you were so kind to try is not working either. Saying ISBLANK is incorrect arguement.
thanks in advance!
SK
thoughts?
Here is the code:
{!REQUIRESCRIPT("/soap/ajax/42.0/connection.js")}
var isFilled = {!NOT(ISBLANK(Contact.Termination_Date__c ))};
if( isFilled){var contactRec = new sforce.SObject( "Contact" );
var records = sforce.connection.query("SELECT Id, Offboarding_Process_Builder_Trigger__c FROM Contact Where id = '{!Contact.Id}'");
var contactRec = records.getArray('records')[0];
contactRec.Offboarding_Process_Builder_Trigger__c = {!Contact.Offboarding_Process_Builder_Trigger__c} + 1;
sforce.connection.update([contactRec]);
window.location.reload();}
else {alert( "Termination Date is required." );}
Riskonnect_Department__c which is a picklist and Escort_Day_1__c which is a lookup to contact