API for 'Create Application File from Record'

The SN Nerd
Giga Sage
Giga Sage

Does anyone know the API to create an Application File?

I am trying to automate the functionality below:

list choice.png

create application file for record.PNG

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
5 REPLIES 5

Chuck Tomasi
Tera Patron

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.


Do you have any idea what the sys_metadata_link table is for?


Roughly, it's the list of files associated with your application. Business rules, tables, fields, etc. all get put there. It is used to generate update sets (if you choose to do that) or commit to source control.



find_real_file.png


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?