+ Start a Discussion

Trigger Help


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.
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.



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.