pbustin Outstanding Contributor.
Outstanding Contributor.
110 views

How can I get a message from an SBM appscript onto the UI?

Jump to solution

I know how to display a message from appscript to the event viewer, but I seem to recall that I once used a call to display a message onto the UI form, even if it meant causing an error to do so.  My questions are: Is there a way to display a message at the top of the UI form, and do I need to cause the script to produce an error in order to display that message?

0 Likes
1 Solution

Accepted Solutions
Highlighted
PM Thompson Acclaimed Contributor.
Acclaimed Contributor.

Re: How can I get a message from an SBM appscript onto the UI?

Jump to solution

Answer is "it depends" (don't ya just hate those 😉   )

The easiest way is if your AppScript or ModScript is running in post-transition context.  Before it "exits" and returns control to SBM, write a string to "Shell.RedoMessage".  That will cause the transition to fail.  SBM will redisplay the item in transition with the text in an error box requiring user intervention.  Write an empty string to "Shell.RedoMessage" to allow the transition to complete without errors.

If your script is running in pre-transition context, one way to get messages to the user is to write them into a text field.  For a couple apps we have Description field set to plain text and put the message there.  JavaScript on the form (you could also use Form Actions) looks for anything in that field and if it finds anything, shows the Description field at the top of the form with a big font.  If the Description field is empty, the Form Action/JavaScript hides the Description field.

 

View solution in original post

2 Replies
Highlighted
PM Thompson Acclaimed Contributor.
Acclaimed Contributor.

Re: How can I get a message from an SBM appscript onto the UI?

Jump to solution

Answer is "it depends" (don't ya just hate those 😉   )

The easiest way is if your AppScript or ModScript is running in post-transition context.  Before it "exits" and returns control to SBM, write a string to "Shell.RedoMessage".  That will cause the transition to fail.  SBM will redisplay the item in transition with the text in an error box requiring user intervention.  Write an empty string to "Shell.RedoMessage" to allow the transition to complete without errors.

If your script is running in pre-transition context, one way to get messages to the user is to write them into a text field.  For a couple apps we have Description field set to plain text and put the message there.  JavaScript on the form (you could also use Form Actions) looks for anything in that field and if it finds anything, shows the Description field at the top of the form with a big font.  If the Description field is empty, the Form Action/JavaScript hides the Description field.

 

View solution in original post

Micro Focus Expert
Micro Focus Expert

Re: How can I get a message from an SBM appscript onto the UI?

Jump to solution

Correct. It is not obvious from the guide, but you can also call Redo.Message() on the pre-transition contact.

There is another option as well.  Add a control to your form to display the message.  Once the form loads, use JavaScript to call a URL ModScript (VBScript will work as well) that takes your input and returns the desired message in json format.  Then update the control.  Here is a sample of that JS.

// 
function checkForm() {
		var resp ;
		var xmlHttp ;
		var RONumber = GetFieldValue("RO_NUMBER");
		var url = "http://server/workcenter/tmtrack.dll?ScriptPage&scriptName=checkForm&find="+RONumber;
	
        resp  = '' ;
        xmlHttp = new XMLHttpRequest();
	xmlHttp.onreadystatechange = function() {
		if (this.readyState == 4 && this.status == 200) {
		  resp = this.responseText;			
		  var obj = JSON.parse(resp);

		  //{"Message":"Do this for the customer." }
		  if ( obj.Message) { 
			// Alert message
			ShowErrorDiv( true, "RO Number already exists: " + RONumber );
		  }
		  else
			ShowErrorDiv(false,"");
		}
	}; //end of form	
         xmlHttp.open( "GET", url, false );
         xmlHttp.send( );
} // end of checkForm

AddLoadCallback( checkForm );

-David

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.