SOLUTIONS WITH BEST POSSIBLE OPTIONS
Friday, April 19, 2013
One to One Relationship in Salesforce
We all know about the 1-M && M-M relationship(using junction Object) in salesforce.
Some times we may need 1-1 relationship among two objects.
but Unfortunately Salesforce doesnot allow any direct methodolgy to build 1-1 relationship
We can achieve the same by workflow or trigger. But workflow is more flexible & the easier way
Steps
-------
Say Two Objects OBJECT-A and OBJECT-B
1- create a look up field in one object
say in OBJECT-A, there is a lookup to OBJECT-B
field Name= obj-B (say)
2- Create another textfield at same Object with unique property (used to hold same obj-B field value)
fieldName= unique_Obj-B (say)
3- Define a workFlow Rule /Trigger to Update the custom "unique_Obj-B" field with the value of the associated OBJECT-B ID.(i.e the field value of "obj-B")
Now we have done with 1-1 Relationship
When we try to add a second same OBJECT-B to the OBJECT-A, the "unique" constraint in OBJECT-A (field "unique_Obj-B")would be violated and an error would be thrown.....
Subscribe to:
Post Comments (Atom)
This is Nice Post, It is quite helpful .
ReplyDeleteNice post..
ReplyDeleteNice blog.Thanks for sharing useful information on Sales force.
ReplyDeletenice, is there any live example with image, how to use workflows
ReplyDeleteThis is helpful but what would be condition for workflow rule..when it will going to fire?Please help me out
ReplyDeleteyou can put condition like
Delete1- ID != null
OR
2- the lookup field != NUll
you can put condition like
ReplyDelete1- ID != null
OR
2- the lookup field != NUll