• Shawn Kaiser 7
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 8
    Replies
I have the below formula field that is going over the max size limite of 5000. I need to figure out a way to get this to work hopefully without APEX. Does anyone know of a way to either break downt he "CASE(MOD..." of this formula? We considered doing a workflow or process builder but we need this to fire every day not just upon create or edit. If the only way to do this is via APEX can I get some help with the code?
If(ISPICKVAL( Status ,"Assigned"), 
CASE(MOD( DateValue(Assigned_Date_Change__c) - DATE(2007,1,1),7), 
0 , CASE( MOD( Today() - DateValue(Assigned_Date_Change__c) ,7),1,2,2,3,3,4,4,5,5,5,6,5,1), 
1 , CASE( MOD( Today() - DateValue(Assigned_Date_Change__c) ,7),1,2,2,3,3,4,4,4,5,4,6,5,1), 
2 , CASE( MOD( Today() - DateValue(Assigned_Date_Change__c) ,7),1,2,2,3,3,3,4,3,5,4,6,5,1), 
3 , CASE( MOD( Today() - DateValue(Assigned_Date_Change__c) ,7),1,2,2,2,3,2,4,3,5,4,6,5,1), 
4 , CASE( MOD( Today() - DateValue(Assigned_Date_Change__c) ,7),1,1,2,1,3,2,4,3,5,4,6,5,1), 
5 , CASE( MOD( Today() - DateValue(Assigned_Date_Change__c) ,7),1,0,2,1,3,2,4,3,5,4,6,5,0), 
6 , CASE( MOD( Today() - DateValue(Assigned_Date_Change__c) ,7),1,1,2,2,3,3,4,4,5,5,6,5,0), 
999) 
+ (FLOOR(( Today() - DateValue(Assigned_Date_Change__c) )/7)*5) 
+Assigned_Duration__c-1,Assigned_Duration__c)
I have a button that I have incorporated some validation rule into for fields that need to be filled in. I am having issue with the fields that are picklists. Below is the code I have but the error I am getting is:<span class="errorStyle">Error: Syntax error. Missing '}'</span>

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

var isFilled = {!NOT(ISBLANK( Contact.Start_Date__c  ))};
var isFilled = {!NOT(ISBLANK( Contact.Escort_Day_1__c ))};
var isFilled = {!TEXT( Contact.Preferred_Computer__c  <>  '' ))};
var isFilled = {!TEXT( Contact.Office_Location__c  <>  ''  ))};
var isFilled = {!TEXT( Contact.Riskonnect_Department__c  <>  ''  ))};
var isFilled = {!TEXT( Contact.Accounting_Department__c  <>  '' ))};

if( isFilled){var contactRec = new sforce.SObject( "Contact" );
var records = sforce.connection.query("SELECT Id, Onboarding_Process_Builder_Trigger__c FROM Contact Where id = '{!Contact.Id}'");
var contactRec = records.getArray('records')[0];  



    contactRec.Onboarding_Process_Builder_Trigger__c = {!Contact.Onboarding_Process_Builder_Trigger__c} + 1; 

 sforce.connection.update([contactRec]); 
    window.location.reload();}

else {alert( "Employment Section is required." );}
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 am looking for code for a trigger to:
1. convert a lead to an existing contact and account if already exists based on the domain. Can this code be written with a button that the users can control, by selecting the button it will check for existing domain and if so it will convert the lead.
2. Have a mass conversion take place nightly to do the same as #1
Much appreciated in advance
SK
I have a button that I have incorporated some validation rule into for fields that need to be filled in. I am having issue with the fields that are picklists. Below is the code I have but the error I am getting is:<span class="errorStyle">Error: Syntax error. Missing '}'</span>

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

var isFilled = {!NOT(ISBLANK( Contact.Start_Date__c  ))};
var isFilled = {!NOT(ISBLANK( Contact.Escort_Day_1__c ))};
var isFilled = {!TEXT( Contact.Preferred_Computer__c  <>  '' ))};
var isFilled = {!TEXT( Contact.Office_Location__c  <>  ''  ))};
var isFilled = {!TEXT( Contact.Riskonnect_Department__c  <>  ''  ))};
var isFilled = {!TEXT( Contact.Accounting_Department__c  <>  '' ))};

if( isFilled){var contactRec = new sforce.SObject( "Contact" );
var records = sforce.connection.query("SELECT Id, Onboarding_Process_Builder_Trigger__c FROM Contact Where id = '{!Contact.Id}'");
var contactRec = records.getArray('records')[0];  



    contactRec.Onboarding_Process_Builder_Trigger__c = {!Contact.Onboarding_Process_Builder_Trigger__c} + 1; 

 sforce.connection.update([contactRec]); 
    window.location.reload();}

else {alert( "Employment Section is required." );}
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 am looking for code for a trigger to:
1. convert a lead to an existing contact and account if already exists based on the domain. Can this code be written with a button that the users can control, by selecting the button it will check for existing domain and if so it will convert the lead.
2. Have a mass conversion take place nightly to do the same as #1
Much appreciated in advance
SK