function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JotmenowJotmenow 

Trigger Help

Hi,

Iam begining to get hands on development.

4 custom fields on object(SalesRep_to_Terr__c)
 
1.Salesrep__c          : Lookup to User Object.
2.Territory__c           : Lookup to Territory object
3.Active__c              : Checkbox(True/False)         
4.Effective_period__c     : Picklist(Jan/Jul)
 
 
Need to create a trigger which would allow only below data.
 
If ACTIVE
 
Once a Salesrep(S1) selects a territory(T1), same combination should exist.
 
Salesrep S1 can never select any other territory.
Territory(T1) should not be associated with any other salesrep.

Can anyone help with code.

Thanks much n advance.

Tried doing it without custom code, could not figure out..Appreciate help.
suresh.csksuresh.csk

Hi.

 

If your going to input only using salesforce than easy one is go for validation rules.

 

In User Object create a field called Type__c(Picklist 1,2,3)

In Territory Object create a field called Type__c(Picklist 1,2,3)

 

Add the below validation to the object SalesRep_to_Terr__c)

 

AND(VALUE(TEXT(Salesrep__c__r.Type__c )) != VALUE(TEXT(Territory__c__r.Type__c) ),Active__c == true)

 

if you need trigger please apply th same logic.

 

cheers

suresh