how to copy a property value of type "password2" value from global scope to private scope?

ramireddy
Mega Guru

Hi,

We have a property of type "password2" in our previous version of application, which is built in global scope. Now, we are creating private scoped app. So, while migrating this property value, I am getting "null" value. what is the workaround for this?

In a scheduled job, i have following 2 lines of code. While URL is returning correctly, "password2" property is not returning correctly and null value is returning.

gs.info("Url:" + gs.getProperty("com.url"));

  gs.info("Secret:" + gs.getProperty("com.secret"));

1 ACCEPTED SOLUTION

Thank you for the clarification.



As you may have already found out, the gs.setProperty() method is not available in scoped apps. However, you might be able to do this with a Fix Script. I believe those run in the global scope. I'd have to double check. The Fix Script will run when the scoped app is installed (using the publish/install method, not update sets.)



Give it a try and let me know.



Fix Scripts - ServiceNow Wiki


View solution in original post

9 REPLIES 9

Thank you for the clarification.



As you may have already found out, the gs.setProperty() method is not available in scoped apps. However, you might be able to do this with a Fix Script. I believe those run in the global scope. I'd have to double check. The Fix Script will run when the scoped app is installed (using the publish/install method, not update sets.)



Give it a try and let me know.



Fix Scripts - ServiceNow Wiki


Hi Chuck,



gs.getProperty() itself returning NULL value. Even it's not able to retrieve a "password2" field.


As I am not able to access "gs.setProperty()", I made a design change. Instead of using properties, I put these properties into a table and started using that table. At the time of migration, I am able to copy all property values of different types. Only password2 value is giving NULL.



gs.getProperty("com.companyname.category.secret')



Meanwhile, I will check whether I can use "Fix scripts".


Hi Chuck,



I am able to implement this via fix script. However, i have already a scheduled job, which is doing remaining almost 99% migration. Is there any way, I can call one from another?   Either call fix script from scheduled job or vice-versa?



This will help customers/users to run only 1 job, either scheduled job or fix script.



Thanks


Rami Reddy


I don't know of an easy way to call one script from another. Scheduled jobs are meant to run on a timed basis (or on demand when someone hits Execute Now.)



If the script only needs to be run once when the app is installed, then a fix script is more appropriate. Move your scheduled job code to the fix script and it will run automatically when the app is installed/updated.


Moving scheduled job code to fix script gave me errors like "accessing private scope" objects. I tried to call "scheduled job" from "fix script. Luckily it worked. I think issue is resolved now.