Popup Special Handling Notes when OnChange of the Account field

Ian Hawkins
Tera Contributor

I have seen other people post this question and get some responses suggesting you can do this with a client script, but there is no further information on how to actually do it.
If we set a SHN on an Account, when someone creates a Case and selects that Account, the only time the SHN is displayed is when the Case is saved. We would like any SHN notes assigned to the Account to be displayed in the popup immediately after the Account is selected and not have to wait until the case is saved before we see it.
We have managed to display a popup and show one SHN when we select an account, but this only shows one SHN and does not have the standard SHN popup functionality, such as the Dismiss button, etc which we would like to use.
Is there any way to call the out-of-the-box SHN function that is run when the case is saved, when we change the Account field?
Thanks, Ian

7 REPLIES 7

JR42
Giga Guru

I would love to figure this out as well.  I would like all Special Handling Notes to apply onChange.

Rad4
Tera Expert

Any news about how to do it?

Community Alums
Not applicable

I've taken Ian's notes and created an idea in the portal. 

Please feel free to go upvote it 🙂

Popup Special Handling Notes when OnChange of the Account field 

Woz
Tera Contributor

Its actually not as easy as just creating a client script. so the Idea that @Community Alums  suggested is still worth an upvote

The script include that fetchs all the notes for the UI model does a number of GlideRecord calls to the DB and then uses the returned GR to perform checks such as matching conditions and checking which field the SHN should use. 


Trying to call this UI Page without the record sys_id is going to give you severely  reduced functionality such as not being able to assess conditional special handling notes 

That said if you wanted to create an on change client script just for this one use case and were not worried about the conditional notes or any of the other stuff that requires GlideRecord but leave all the existing OOTB code in place you could.....

1) Create a script include that fetches special handling notes. The OOTB one is "new global.SHNProcessor()"  and has loads of great tools for filtering out notes. The example below is severily reduced from OOTB but you could add more checks later I just wanted to keep this one a simple function that queries the sn_shn_notes table an returns the notes for the current account such as 

 

 

    getPopupAlerts: function(account) {
		
		var notes = [];
		
        if (!gs.nil(current_table) && !gs.nil(id)) {
			var get_notes = new GlideRecord('sn_shn_notes')
			get_notes.addEncodedQuery("table=Account^related_record=" + account)
			get_notes.query();
			while(get_notes.next()){
				notes.push(get_notes.getValue('sys_id'))
			}
		}
        return notes;
    },

 



2)  then clone the UI page special_handling_notes and replace line 22 with a call to your new script include. Notice I am passing an argument called "id" into my new function that will be "account" in your script include. Id comes from the client script

Woz_0-1669365896186.png

 

3) create a client script on your case table as follows NOTE: account in my instance is called organization 

Woz_2-1669366161676.png