How to set an alert when a user opens a catalog item

gunishi
Tera Guru

Hi there, 

 

I have a strangre requirement and not sure how to approach it.

 

Requirement:

If user who has no manager in user table tries to open this catalog item then we should alert the user with message ‘Hey, seems you don’t have manager assigned!’.

 

How would I go about this? Would I start with a business rule? And how would I qualify the 'current user has opened CI of interest'?

 

Any help would be appreciated. 

 

Kind regards, 

G

 

 

1 ACCEPTED SOLUTION

Tai Vu
Kilo Patron
Kilo Patron

Hi @gunishi 

Try this.

#Client Script OnLoad

 

var ga = new GlideAjax('CatalogUtilAJAX');
ga.addParam('sysparm_name', 'getManagerID');
ga.getXMLAnswer(function(response){
    if(response !== ''){
        alert('Hey, seems you don’t have manager assigned!');
    }
});

 

 

#Script Include AJAX

 

/**
 * get Manager ID of current user
 */
getManagerID: function(){
	return gs.getUser().getManagerID();
},

 

 

Let me know if it works for you

 

Cheers,

Tai Vu

View solution in original post

2 REPLIES 2

Tai Vu
Kilo Patron
Kilo Patron

Hi @gunishi 

Try this.

#Client Script OnLoad

 

var ga = new GlideAjax('CatalogUtilAJAX');
ga.addParam('sysparm_name', 'getManagerID');
ga.getXMLAnswer(function(response){
    if(response !== ''){
        alert('Hey, seems you don’t have manager assigned!');
    }
});

 

 

#Script Include AJAX

 

/**
 * get Manager ID of current user
 */
getManagerID: function(){
	return gs.getUser().getManagerID();
},

 

 

Let me know if it works for you

 

Cheers,

Tai Vu

Hi @Tai Vu 

 

This is perfect, thank you! I actually already had a get manager function so this is super useful. 

 

Thank you again.

 

Kind regards, 

G