API for 'Create Application File from Record'

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2016 08:56 PM
Does anyone know the API to create an Application File?
I am trying to automate the functionality below:
Every time I increment my version, I want to automatically add a specific set of records to the application.
Thanks
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2016 12:51 PM
Hi Paul,
Excellent question. I share the curiosity on that one myself.
I reverse engineered that UI action which lead me back to the processing script on the UI page: add_selected_metadata_link_dialog_ui16
At the end of it all, it appears to just inserting/update records in to the sys_metadata_link table. Here's a chunk of the insert code (with variables provided by the UI page form in the HTML section.)
var payloadStr = gs.unloadRecordToXML(linkedRecord, true);
var output = new GlideRecord('sys_metadata_link');
output.query();
output.initialize();
output.payload = payloadStr;
output.documentkey = linkedRecord.sys_id;
output.tablename = current_table;
output.sys_name = linkedRecord.getDisplayValue();
output.directory = dir_choicelist;
output.insert();
It shouldn't be hard to adapt that to a Fix script or your own UI action to populate those same fields with your own meta data.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 05:46 AM
Do you have any idea what the sys_metadata_link table is for?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 05:51 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 05:56 AM
I noticed that I can use the action also in the Global scope, without a custom application. It seems like it just forces the selected records into my update set.
Does this make any sense or do you see a problem with using this action for this purpose?