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.

Rookie Asked on December 10, 2021 in SuiteScript.
Add Comment
2 Answer(s)

Seems like I can do it if I use a Suitelet to do the work. If I call the Suitelet from the Client Script and pass on the customer id, the Suitelet can do session.set and then a User Event can fetch the customer id with session.get on beforeLoad at the contract record.

A little workaround to get a seemingly easy thing done.. If anyone has a better solution, please let me know!

Rookie Answered on December 10, 2021.
Add Comment

You can use window.opener from a client script deployed on the second record to access the window of the parent record. From there, you can use window.opener.require() to access N/currentRecord of the opener window, which would be the currentRecord of record 1.

Advanced Answered on December 13, 2021.

Do you have any example on how the client scripts should look like when using window.opener.require to access record 1? I tried using this example I found in SuiteAnswers, but I don’t really get it to work.

on December 14, 2021.

What did your attempt look like? Keep in mind that coments on this site are useless, there are no notifications for them. Expect to use the slack if you want to have an actual conversation

on December 29, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor