The CreatorCon Call for Content is officially open! Get started here.

How to populate an embedded list with a script? (advanced scripting needed)

Smith Johnson
Tera Guru

Hello all,

I would like to know how can I populate an embedded list. For example, in the following image, all fields of the form (request form) can be populated with a mapping between user's selections and table's fields. However, there is no any option for making a mapping between a record producer's option and a column of an embedded list.

In my case, I want once a user selects an item on Service Portal, this item is populated and appears on the embedded list of the record.

find_real_file.png

I guess it needs advanced scripting techniques, but since I don't have them your assistance would be incredibly valuable for me.

Thank you in advance for your time and your willingness to help me.

Best regards,

Smith.

1 ACCEPTED SOLUTION

To use the cart functionality - test with one catalog item you can pick from the record producer.

1. Add a new variable to the catalog item

  • Type: Reference
  • Table: sc_request

2. Add a UI Policy to hide the variable on load

3. In the BR you have in the REQ table, replace the code with this: 

var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem(current.u_cat_item); 
cart.setVarible(item, 'request', current.sys_id);
var rc = cart.placeOrder(); 

View solution in original post

22 REPLIES 22

@Ankur Bawiskar  My BR is on sc_request table and I want to populate the fields that are in the below red circles.

find_real_file.png

How could I refer to these fields from my BR script?

@Ankur Bawiskar Actually this is the requirement that I need. If you could answer the previous question, I would be so thankful, because it seems that it ll be my solution to my issue.

Hi,

I didn't get your requirement.

Once REQ is inserted you want RITM to be generated by setting the quantity and Item

Please explain your detail business use-case/requirement and what you are trying to achieve

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar  Hi again Ankur,

I have the following record producer that creates a record on sc_request table.

find_real_file.png

Once, I submit the form, a request is created as shown below.

find_real_file.png

So, if you see in the embedded list, it is empty.

 

What I am trying to do is to populate the Item field of the embedded list with the value that the user selected on the record producer.

So, based on what you said I created an after insert BR on sc_request table, and now I would like to know how can I refer to the Item field of the embedded list from the Business Rule's script.

@Ankur Bawiskar something like: current.item.item it's not working ... is it clear what I am trying to do?