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
jnegijnegi 

How to assign predefine date to CampaignMember's FirstRespondedDate .

Hi 

 

As per my business requirement I am deleting my CampaignMember's record and creating new record. Now how can I set the same FirstRespondedDate in new records which were in deleted records.  

Imran MohammedImran Mohammed

If both deletion and creation of records are part of same transaction, then you can use the helpof a temporary Date variable.

You can declare date variable in class and use it to assign FirstRespondedDate and then use this variable to assign it to the new record to be created.

 

If this is not the case, then you have to create a temporary custom object and have to save date against any unique field of CampaignMembers record.

jnegijnegi

Thanks Imran

 

I want to ask how can I assign predefined date to FirstRespondedDate.

 

I am doing like this:-

 

CampaignMember cm = new CampaignMember();

cm.Status = 'responded';

 

when I am doing this it assign FirstRespondedDate as today's date. How can I assign predefined date to FirstRespondedDate through coding.

Imran MohammedImran Mohammed

As you said that old records are deleted  and new campaignmember records are created.

How is the FirstRespondedDate assigned in Old records.?

 

And one more question is is both deletion and new record creation happening at the same time.

jnegijnegi

FIrst Query:-

In CampaignMember there is a Status picklist field which have value as "Sent" and "Responded". When we select Responded another CampaignMember 's boolean field HasResponded set as true,which automatically set FirstRespondedDate.

 

Second Query:-

Yes both operations are happening at same time.