copy a field value on a table to another table's field, using a reference from the original table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2023 01:36 AM
Hi,
I have a table called 'u_iar' which references the 'name' field on the 'cmdb_ci_business_app' table (this is called 'configuration_item' on the origin table and 'name' on the reference table ) as well as having it's own , separate 'name' field on the origina table (yes, I know this is poor practice) with the exact same value . The referenced name field matches the original tables name field currently, despite having no relationship referentially.
on the 'u_iar' table I have a field called 'platform_manager'
on the 'cmdb_ci_business_app' app table I have a field called 'x_enps_iar_applica_platform_manager'
I am wanting to copy the value in 'u_iar.platform_manager' to the 'cmdb_ci_business_app.x_enps_iar_applica_platform_manager' field.
In order to test this I am doing an addQuery on a single record and using background scripts as per below to no avail with the error
Cannot read property "x_enps_iar_applica_platform_manager" from undefined
var gr = new GlideRecord("x_enps_iar_applica_cmdb_ci_information_asset");
var ci = gr.configuration_item
gr.addQuery('name','Member Mobile App')
gr.query();
gr.initialize();
ci.x_enps_iar_applica_platform_manager.name = gr.platform_manager.name;
//add remaining fields as is
gr.update();
any help, greatly appreciated. In a past life I was a dev, but has been too many years in between!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2023 05:22 AM
- First Glide the u_iar table and find that record using addQuery.
- Then store that record platform_manager value (sys_id) in one variable. (eg. var a = 12345)
- Glide the second table.
- Find out the record in that table using addQuery.
- And set that variable to it. (eg. gr.x_enps_iar_applica_platform_manager = a)
- Update the record. (eg. gr.update();)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2023 01:06 PM
Thanks @Pradnyesh . I'm wanting to do this via the reference field (i.e. the configuraiton_item field on the u_iar table, which is a reference to the second table). This is so I can be sure I am referencing each record correctly from it's u_iar table to the cmdb_ci_business_app table. While I'm testing this on one reference, I plan to eventually do this on the entire table.