You need to sign in to do that
Don't have an account?
kumar 420
Create custom field on Contact for sequence number. by help trigger to manage sequence of Contacts on an Account
hello,
i have two standard object Account(parent) and Contact(child) .so i wanna create a custom field 'sequence number' on Contact .
suppose my Account(parent) Object have 5 Contact(child) the 'sequence number' record is 1,2,3,4,5 Than i will delete the One 'sequence number' record 3 so my 4 number come to 3 and 5 number is come to 4. the new 'sequence number' is 1,2,3,4
if i will delete any record than the sequence of record number is maintan.
this is done help by 'Apex Trigger'.
help my and example with code
i have two standard object Account(parent) and Contact(child) .so i wanna create a custom field 'sequence number' on Contact .
suppose my Account(parent) Object have 5 Contact(child) the 'sequence number' record is 1,2,3,4,5 Than i will delete the One 'sequence number' record 3 so my 4 number come to 3 and 5 number is come to 4. the new 'sequence number' is 1,2,3,4
if i will delete any record than the sequence of record number is maintan.
this is done help by 'Apex Trigger'.
help my and example with code
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Trigger:
Class to prevent recursive trigger:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Trigger:
Class to prevent recursive trigger:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
can you give me answer on update query on this custom field
Khan Anas , pls can u share update scenario also
Same as above. But, Small Change in the question
If Ihave two standard object Account(parent) and Contact(child) .so i wanna create a custom field 'sequence number' on Contact .
suppose my Account(parent) Object have 5 Contact(child) the 'sequence number' record is 1,2,3,4,5 Than i will delete the One 'sequence number' record 3 so my 4 number should not come to 3 and 5 number should not come to 4. The new 'sequence number' is 1,2,4,5 . The place of 3 should not be filled. If we want add new Contact 6, then the sequence should continue like 1, 2, 4, 5, 6
If I will delete any record than the sequence of record number is maintaned and the deleted field should not be filled.
this is done help by 'Apex Trigger'.
help my and example with code