Create Mass Records

This function is used to create mass records and it returns a message result that contains the GUIDs of the newly created ones and the errors.

  • Function: CreateMassRecords(<Object Name>, <Matching Field>, <XML Data>, <use ExternalID>)
    • var ObjResult = CreateMassRecords(<Object Name>, <Matching Field>, <XML Data>, <use ExternalID>);
    • var message = msgInfo;
    • Use External Id: if the value is false, then you must send the GUID of the lookup fields in the XML data otherwise send the external Id value. Also if the parameter useExternalID is not existing in the function parameters, then it will considered as it is set to true.

XML Data Format:

"<Data>"
"<Object Name>"
"<Matching Field Name>"
   Value1
"</Matching Field Name>"
"<Field Name>"
   Value1
"</Field Name>"
"<Field Name>"
   Value1
"</Field Name>"
"</Object Name>"
"<Object Name>"
"<Matching Field Name>"
   Value2
"</Matching Field Name>"
"<Field Name>"
   Value2
"</Field Name>"
"<Field Name>"
   Value2
"</Field Name>"
"</Object Name>"
"</Data>"
  • Usage:
var xmlStr = "<Data>";
xmlStr += "<Contact>";
xmlStr += "<Name>";
xmlStr += "Elise Alice";
xmlStr += "</Name>";
xmlStr += "<First_Name>";
xmlStr += "Elise";
xmlStr += "</First_Name>";
xmlStr += "<Last_Name>";
xmlStr += "Alice";
xmlStr += "</Last_Name>";
xmlStr += "<Email>";
xmlStr += "elise.alice@gmail.com";
xmlStr += "</Email>";
xmlStr += "<OwnerId>";
xmlStr += "freddy.fares@aliston.fr";
xmlStr += "</OwnerId>";
xmlStr += "<IsDeleted>";
xmlStr += 0;
xmlStr += "</IsDeleted>";
xmlStr += "</Contact>";
xmlStr += "<Contact>";
xmlStr += "<Name>";
xmlStr += "John Smith";
xmlStr += "</Name>";
xmlStr += "<First_Name>";
xmlStr += "John";
xmlStr += "</First_Name>";
xmlStr += "<Last_Name>";
xmlStr += "Smith";
xmlStr += "</Last_Name>";
xmlStr += "<Email>";
xmlStr += "john.smith@gmail.com";
xmlStr += "</Email>";
xmlStr += "<OwnerId>";
xmlStr += "freddy_fares@aliston.fr";
xmlStr += "</OwnerId>";
xmlStr += "<IsDeleted>";
xmlStr += 0;
xmlStr += "</IsDeleted>";
xmlStr += "</Contact>";
xmlStr += "</Data>";

var ObjResult = CreateMassRecords("Contact", "Email", xmlStrContact, true);
var message = ObjResult.msgInfo;
  • Output:

    • The result message will be displayed as follow:
      • Success Records: Name + “ – “ + Record GUID + “ – “ + True
      • Failed Records: Name + “ – “ + Error Message + “ – “ + False
    • Example:
      • “John Smith – OwnerId: Lookup Multi-Relationships Field contains invalid value – False;Elise Alice – 1825492168588921251 – True;”
    • If the field “Name” is of type AutoNumber, in order to get the name in the message result, we need to put the tag name in the xml data without any data as follow:
      • xmlStr += “<Name>”;
      • xmlStr += “</Name>”;
    • The succeeded records will have the name displayed while the failed records don’t in the message result:
      • Example:
        ” – OwnerId: Lookup Field contains invalid value – False;TR00010 – 1826049184390712154 – True; “
    • If we didn’t put the tag “Name” in the xml data, then the result will be displayed as follow:
      • Example:
        ” – OwnerId: Lookup Field contains invalid value – False; – 1826049184390712154 – True;”
Was this article helpful to you? Yes No

How can we help?