This topic contains 0 replies, has 1 voice, and was last updated by Radek Radek 4 years ago.

  • Author
    Posts
  • #26133 Score: 0

    Radek Radek
    Member
    • Contributions: 1
    • Level 1
    @radek_radek

    Hello everyone,

    I am not able to return new record ID after I creating it using RESTlet. I read some articles that pointed me to afterSubmit function, but still not able to achieve what I need. Creation work fine, but I need it to return ID of newly created record and pass it to other automatisation we use.

    Code:

    define([‘N/search’, ‘N/record’],

    function (search, record) {

     

    function afterSubmit(scriptContext) {

    var recordid = scriptContext.newRecord.id;

    }

    function doPost(requestBody) {

    var foo = requestBody[‘foo’]

    require([“N/record”], function (r) {

     

    var new_record = r.create({type: “custom_record”});

    new_record.setValue({fieldId: ‘foo’, value: foo});

     

    // more set values

    new_record.save()

    });

    return {

    afterSubmit: afterSubmit;

    };

    }

     

    Can someone help please ? I need to work with JS only in this case and I am kinda lost in it. Any suggestions/help is more than appreciated.

     

You must be logged in to reply to this topic.