RE: Pull data to ‘add new popup’ from the originating record in create mode

We have 2 custom records from a SuiteApp that our client has purchased.

In custom record 1, we have 2 drop down list fields for customer and for contract,

In create mode, a customer is selected. If the customer does not already have a contract, we have to add it. We do so using the ‘+’ button next to the contract field.

This opens our custom record 2: contract. Here we have a field for customer and some contract data fields.

Our client wants the customer entered in the 1st custom record to automatically follow to the contract and populate the customer field there.

Is this even possible? Since we are in create mode we do not have an id for the 1st custom record so we cannot just add a field to the contract that is linked to the 1st custom record and pull the data that way.

I was considering session.set and session.get, But I can only do that with a server side script.. And I need a client script to notice the field change on customer in custom record 1.

maza Rookie Asked on December 10, 2021 in SuiteScript.
Add Comment
3 Answers

You are right, I did not notice your comment. I managed to solve this using the example in SuiteAnswers and your input about using the currentRecord of record 1.

It looked like this, if it might help someone else in the future:

function pageInit(context) {
    if (window.opener){
        const childRec = currentRecord.get()
        const testData = 'TEST'
        window.opener.require(['N/currentRecord'], function(currentRecord){
            const parentRec = currentRecord.get()
            parentRec.setValue({ fieldId: 'memo', value: testData })
            const customer = parentRec.getValue({ fieldId: 'entity' })
            childRec.setValue({ fieldId: 'custrecord_test_customer', value: customer })
        })
    }
}
Rookie Answered on February 17, 2022.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.