You need to sign in to do that
Don't have an account?
Casey Conner 20
Solution to clone a record many times automatically
I am looking for suggestions on a solution I am trying to build. Let me try to explain.
Here are my objects. Notice__c, Notification__c, Notice Group__c, Notice Group Member__c
I want to be able to create a Notice record. Each Notice is related to a Notice Group. Each Notice Group has a set of Notice Group Members__c. Once a Notice it published (status value = published), a notification record should be created for each Notice Group Member__c associated with the selected Notice Group.
The purpose is to create a notice for an audience of users, but allow individual tracking of the timing of notice acknowledgement. Therefore, each user has their own clone of the Notice record to interact with.
I am trying to evaluate the best way to implement this solution using any combination of workflow tools / Apex. Thanks!
Here are my objects. Notice__c, Notification__c, Notice Group__c, Notice Group Member__c
I want to be able to create a Notice record. Each Notice is related to a Notice Group. Each Notice Group has a set of Notice Group Members__c. Once a Notice it published (status value = published), a notification record should be created for each Notice Group Member__c associated with the selected Notice Group.
The purpose is to create a notice for an audience of users, but allow individual tracking of the timing of notice acknowledgement. Therefore, each user has their own clone of the Notice record to interact with.
I am trying to evaluate the best way to implement this solution using any combination of workflow tools / Apex. Thanks!
Please describe the relation of Notification__c with any object. So we can figure it out.
Could you post the schema diagram of these objects as the above detail is not clear about the object relation ship? You can use the schema builder option of salesforce.
Here you go. Sorry, I should have included it in the original. Also, my object names on the schema are a little different than originally labeled.
So to elaborate, if a Notice is created and the associated Recipient Group has 5 Recipient Group Member records, then the code/workflow should create 5 Notification records and assign each to the 5 Recipient Group Member records.
you can use After Insert trigger on Notice Object. Here is the below example of code that you can refer for your scenario.
Let me know if you need any clarification.
Apologies from my end for replying on so late on this.
After assuming the api names as i don't have any idea of api names.
I have tried and added some comments to simply what is being done below:
- First we checked if status field is changed , if changed does the changed value is a Published
- We query all the group memeber as we know the notice.
- Create a map of notice and correspong users so that when we loop through the notice records we can find group member user , and create notification records
Hope this help!