Need to update records with record producer

Jess Larsen1
Tera Expert

Hi.

 

I need to update records on assets so it can be used for assigning assets to users. 

On the portal certain users need to be able to assign an asset to others so if they look up the asset in hand by a lookup selectbox and then have another lookup select box where they can find the user, the producer needs to update the existing record and not make a new. 

 

I have made the fields that is needed in the form, but it keeps making a new record and not updateing the existing. 

 

The table I am trying to update is alm_asset so I think I´m in the right place?

 

Hope someone can help me.

 

Best Regards

Jess Larsen

 

 

1 ACCEPTED SOLUTION

Jess Larsen1
Tera Expert

var usrGR = new GlideRecord('alm_asset');
usrGR.addQuery('sys_id', producer.v_lg_computer);
usrGR.query();
if (usrGR.next()) {
usrGR.assigned_to = producer.select_employee;
usrGR.install_status = 1;

usrGR.update();
}
gs.info(producer.select_employee);
gs.info(producer.v_lg_computer);

current.setAbortAction(true);
producer.portal_redirect = "id=sc_category";

View solution in original post

5 REPLIES 5

OlaN
Giga Sage
Giga Sage

Hi,

You could solve it, within the scripting section of the record producer by using current.setAbortAction(true)
But a better way would be to go for a regular Catalog Item instead of using a record producer.

Create a Flow to connect to that catalog item, and execute a few actions as needed within the flow.

Trigger: Service catalog

Action1: Get catalog variables
Action2: Look up Asset record using input in action1
Action3: Update Asset found in action2 using inputs in action1
Action4: Close complete the RITM

Sushma R1
Tera Expert

Record producers are meant to be used for creating task based records, and better leave it alone and i dont think so it's better to do this with catalogs either, try to create a portal page(restrict it to the role you want to see this page) which has a widget > widget has 2 sn-record-pickers (1 for asset one for user)and run a script in your server side to update the alm_asset.

I did this long back for self hardware asset verification purposes.

 

Hit helpful if it was 🙂

Hi. 

Do you have an example on how you did this? just to know more about where to start since i´m very new at this 🙂

Jess Larsen1
Tera Expert

var usrGR = new GlideRecord('alm_asset');
usrGR.addQuery('sys_id', producer.v_lg_computer);
usrGR.query();
if (usrGR.next()) {
usrGR.assigned_to = producer.select_employee;
usrGR.install_status = 1;

usrGR.update();
}
gs.info(producer.select_employee);
gs.info(producer.v_lg_computer);

current.setAbortAction(true);
producer.portal_redirect = "id=sc_category";