How to override function from This item is read-only based on its protection policy script include ?

Serj
Tera Contributor

Hi guys, I need to override two functions in script include which is 'This item is read-only based on its protection policy'

how can I resolve it? 

 

 
1 ACCEPTED SOLUTION

Yes you can extend it similar to what I posted.

InteractionFacadeCustom = Class.create();

InteractionFacadeCustom.prototype = Object.extendsObject(InteractionFacade, {

	functionNameYouWantToOverride: function() {
		...
	},

	type: "InteractionFacadeCustom"
});

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

8 REPLIES 8

Mark Roethof
Tera Patron
Tera Patron

Hi there,

2 things jump in mind.

You could create a new Script Include, which extends the current one. In that new Script Include, you could just add a function with the same name. You could then just reference that new Script Include and Function.

Other possibility. For some Script Includes, out-of-the-box there is a read-only version and already an extended version which is intended to edit. This extended version is already the one which scripting etc is pointing to.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Chander Bhusha1
Tera Guru

Hi Serj,

You can create a new script include and extend the readonly script include and add the function there.

 First check if there is an additional script include with the same name without SNC  there OOB they have created one for update purpose. If that is not there then you can use this approach,

Update the name of readonly script include in there readonlyscriptinlcudename.

and add the function which you need to update here.

function to be update is updatefunction 

 

Your new script include will look like this: add the Object.extendsObject

 

var newscriptinclude= Class.create();
newscriptinclude.prototype = Object.extendsObject(readonlyscriptinlcudename, {

 

updatefunction :function(){

},

 

 

type: 'newscriptinclude'
});

  

Thanks,

CB

Mark Roethof
Tera Patron
Tera Patron

Here an example of what I mean with some out-of-the-box Script Includes which already have an extended Script Include, which you could edit:

Script Include:

KBKnowledgeBase
and
KBKnowledgeBaseSNC

Code of the KBKnowledgeBase:

KBKnowledgeBase = Class.create();

KBKnowledgeBase.prototype =  Object.extendsObject(KBKnowledgeBaseSNC, {

	type: "KBKnowledgeBase"
});

So you could just add the function name you are after, and add your code for example. Again it depends obviously if you have such a Script Include. If not, set it up, and change your script/reference etc. to point to this extended script include.

SNC being the read-only one. The non SNC the extended Script Include which you can edit. for example to override out-of-the-box functions in the SNC version.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

if my read-only script without SNC can i extend it ? 

My read-only script InteractionFacade 

InteractionFacadeCustom = Class.create();

InteractionFacadeCustom.prototype = Object.extendsObject(InteractionFacade,{

} ?