1. Accueil
  2. /
  3. Guide Développeur
  4. /
  5. Librairie JavaScript
  6. /
  7. Création d’un enreg...

Création d’un enregistrement

Cette fonction est utilisée pour créer un nouvel enregistrement et renvoie son GUID avec un message d’information

  • Function: CreateRecord(<Object Name>, <Matching Field>, <XML Data>, <use ExternalID>)
    • var ObjResult = CreateRecord(<Object Name>, <Matching Field>, <XML Data>, <use ExternalID>);
    • var NewRecordGUID = ObjResult.RecordGUID;
    • 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:

“<Object Name>”
“<Matching Field Name>”


“</Matching Field Name>”
“<Field Name>”


“</Field Name>”
“<Field Name>”


“</Field Name>”
“</Object Name>”

  • Usagevar objTask = GetDataByID(GetRecordGUID(),“Task”, “Id,Name,Start,End,Description,Location,Attendees,OwnerId,IsDeleted”);

var offset = GetTimeZone();
var xmlStr = “<Data>”;
xmlStr += “<Task>”;
xmlStr += “<Name>”;
xmlStr += “Client Meeting”;
xmlStr += “</Name>”;
xmlStr += “<Start>”;
xmlStr += objTask.Start + offset;
xmlStr += “</Start>”;
xmlStr += “<End>”;
xmlStr += objTask.End + offset;
xmlStr += “</End>”;
xmlStr += “<Description>”;
xmlStr += objTask.Description;
xmlStr += “</Description>”;
xmlStr += “<Location>”;
xmlStr += objTask.Location;
xmlStr += “</Location>”;
xmlStr += “<Attendees>”;
xmlStr += objTask.Attendees;
xmlStr += “</Attendees>”;
xmlStr += “<OwnerId>”;
xmlStr += objTask.OwnerId;
xmlStr += “</OwnerId>”;
xmlStr += “<IsDeleted>”;
xmlStr += 0;
xmlStr += “</IsDeleted>”;
xmlStr += “</Task>”;
xmlStr += “</Data>”;

var ObjResult = CreateRecord(“Task”, “Id”, xmlStr, false);
var TaskGUID  = ObjResult.RecordGUID;
var message = ObjResult.msgInfo;

  • Output:
    • Success:
      The following message will be displayed “New record is created successfully.”
      It will return the GUID of the newly created record.
    • Failure:
      An error message will be displayed.
      The GUID will be null.

Cet article vous a-t-il été utile ? Non Oui

Comment pouvons-nous aider ?