-1

Im trying to create a new activity from each individual value. What I have done so far is shown below in snippets to get each value.

var Names = recordRow.Cells[0].Value.ToString().Split(",".ToArray(),StringSplitOptions.RemoveEmptyEntries);'

For each value in in the cell, populate a field in the activity form

 foreach (var Name in Names)
                    {
                        newAct.RegardingObjectId = new EntityReference(Lead.EntityLogicalName, actualCRMLead.Id);
                        _xrm.Create(newAct);
                    }

How do it create a new activity once the RegardObjectId field in populated?

Thanks,

EDIT 1; If there are 3 names in the one cell it will create 9 activities, how can I stop it from creating duplicates?

Joseph Duty
  • 775
  • 5
  • 14
AndroidAL
  • 1,111
  • 4
  • 15
  • 35
  • _xrm.Create(newAct) should be sufficient to create a new activity. Without a more holistic code set, there's no way to say how to prevent duplicates. What exactly is your rule for determining what is a duplicate? – Joseph Duty Sep 24 '15 at 19:20

1 Answers1

0

Assuming _xrm is the variable that stores the Organization Service Object (and that was properly instantiated), then you have the correct snippet to create a newAct object and to set the regarding field to the "actualCRMLead"

Joseph Duty
  • 775
  • 5
  • 14