Migrate scoped app from developer instance to company instance

jason_lau
Tera Contributor

Hi,

If you create a scoped app from a developer instance (organization-code = 12345), is there a way to migrate or convert that application to your company namespace (for example: organization-code=myco)?

Or if you create a scoped app from a developer instance and you want it under your company namespace, do you have to rebuilt the objects into that new namespace?

Basically, I created some scoped apps in a developer instance before we got our company instances and I'd like to see if theres a way to change/migrate the scoped app(s) to new namespace. I'm assuming that even if it's possible there would be some manual search/replace work needed to be done, for example in include script which references a scoped application table (x_12345_appname_tablename, etc).

Thanks!

Jason

1 ACCEPTED SOLUTION

Further investigation says you can update all artifacts by querying table sys_metadata


var gr = new GlideRecord('sys_metadata');  


gr.addQuery('sys_scope','821b35cd4f442200bbc32d118110c7f2'); //sys_id of the first scoped app


gr.query();


while(gr.next())


{


gr.sys_scope = '96784d274f10e600bbc32d118110c7de'; //Update with correct scope i.e newly created scoped app  


gr.setWorkflow(false);  


gr.update();  


}



To round of testing by creating a sample app and updating it to new the app.


View solution in original post

10 REPLIES 10

Here is sample script which you can trigger from Background-script. For ex to update business rule scope from previous to the newly created.


var gr = new GlideRecord('sys_script');


if(gr.get('40343ff00fcf0e00304f3b8ce1050ef0')){ //all records with application scope created


gr.sys_scope = '40343ff44fcf0e00304f3b8ce1050ef0'; //Update with correct scope i.e newly created scoped app


gr.setWorkflow(false);


gr.update();


}


Background Scripts — ServiceNow Elite



You can update this script as per your req.


Further investigation says you can update all artifacts by querying table sys_metadata


var gr = new GlideRecord('sys_metadata');  


gr.addQuery('sys_scope','821b35cd4f442200bbc32d118110c7f2'); //sys_id of the first scoped app


gr.query();


while(gr.next())


{


gr.sys_scope = '96784d274f10e600bbc32d118110c7de'; //Update with correct scope i.e newly created scoped app  


gr.setWorkflow(false);  


gr.update();  


}



To round of testing by creating a sample app and updating it to new the app.


Thanks Pradeep, I'll lab test this with a sample app and report back to thread. While it's likely not supported, it seems like that's what I would need to do (create new app in correct namespace, import prior app, and update objects to new app.


Thanks Jason for the update.


Please let me know the results once this task is completed.


Hi Pradeep, yes I did this with a sample application and I can move the files to a new scoped application under correct namespace, and that seems to to the trick.



1. import scoped app (old) from source control to the company instance


2. Create a new scoped app (new) with the same app name.


3. Ran your update script to update sys_metafile records to correct sys_scope (new).



At this point, all of my objects show up in the new scoped app under correct company code. I can, through studio, find all of my in-code references to old namespace and update those. What's the best way though to update objects prefixed with the old namespace, like roles, ACLs, tables? I don't think I can/should edit those directly from git repository since I think that would break the checksum if I do so outside of ServiceNow instance.



[I'm using Helsinki with Studio and Gitlab for source code repository. I guess I could export update set and update there, but I'm trying to keep everything under source code management.]