sage-crm

Sage CRM - There is method to retrieve the ID on the recently created record when using CRM.CreateRecord object?


Given this code:

var NewComm = CRM.CreateRecord("Communication");
NewComm("Comm_ChannelId") = Request.Form("chanId");
NewComm("Comm_Type") = "Appointment";
NewComm("Comm_DateTime") = Request.Form("initialHour");
NewComm("Comm_Status") = "Pending";
NewComm("Comm_Priority") = "Normal";
NewComm("Comm_Action") = "Meeting";
NewComm("Comm_SecTerr") = Request.Form("secTerr");
NewComm("Comm_Subject") = "No Subject";
NewComm("Comm_Note") = "No notes";
NewComm.SaveChanges();

There is a method of the CreateRecord Object to retrieve the ID of the recently created record?


Solution

  • Once you have created the new record, the Id becomes available in the object. Using your example above, you can simply get the Id with this code:

    NewComm.SaveChanges();
    var CommId = NewComm("Comm_CommunicationId");
    

    This applies to any record type with the same method.

    Six Ticks Support