WAB: How do I customize output messages in GP Widget Output tab?

4335
18
Jump to solution
08-30-2017 07:52 AM
FrancescoTonini2
Occasional Contributor II

Can anyone help me understand what file(s) and code chunks I need to look at to customize the info, warning, or error messages that get sent to the Output tab of the GP Widget in WAB? Related to this, what should I do if I wanted to output my own custom messages into an on-screen message window that opens only after GP widget is done executing? Thanks!

1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Francesco,

   In the Geoprocessing widget.js find the onExecuteComplete function in there you will see that the only messages that are dealt with are warnings and errors:

    onExecuteComplete: function(results){
      this._hideLoading();

      //show messages if there are warning or error
      var msgs;
      if(results.messages && results.messages.length > 0){
        msgs = array.filter(results.messages, function(msg){
          return msg.type === GPMessage.TYPE_WARNING ||
                 msg.type === GPMessage.TYPE_ERROR;
        });
        if(msgs.length > 0){
          this._createErrorMessages(msgs);
        }
      }

      //the results.results is an array of ParameterValue,
      //because it contains one or more parameters
      this._createOutputNodes(results.results);

      html.removeClass(this.exeNode, 'jimu-state-disabled');
    },

View solution in original post

18 Replies
RobertScheitlin__GISP
MVP Emeritus

Francesco,

   In the Geoprocessing widget.js find the onExecuteComplete function in there you will see that the only messages that are dealt with are warnings and errors:

    onExecuteComplete: function(results){
      this._hideLoading();

      //show messages if there are warning or error
      var msgs;
      if(results.messages && results.messages.length > 0){
        msgs = array.filter(results.messages, function(msg){
          return msg.type === GPMessage.TYPE_WARNING ||
                 msg.type === GPMessage.TYPE_ERROR;
        });
        if(msgs.length > 0){
          this._createErrorMessages(msgs);
        }
      }

      //the results.results is an array of ParameterValue,
      //because it contains one or more parameters
      this._createOutputNodes(results.results);

      html.removeClass(this.exeNode, 'jimu-state-disabled');
    },
FrancescoTonini2
Occasional Contributor II

Thanks Rob! Would I still only get warning and error messages even when I set up my GP service to "Info" level? If that is the case, then I could add more warning messages to my GP service code to have those written in the output of the widget (without having to modify it)...am I correct? However, what if I wanted to, say, have an "info" type of message popping up on my screen after running GP widget, with some summary info such as "total CO2 emission" etc? Would I have to modify and add to that same chunk of code you pasted above?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Yes you are correct on both accounts.

RyanDeBruyn1
New Contributor III

Quick question.  Where/how do I find the .js file for the gp widget that was created and configured in WAB? or does this have to be a custom widget?

thanks

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ryan,

   If you are using WAB Developer then you look in the apps widgets folder (i.e. [Install dir]\server\apps\[app#]\widgets\Geoprocessing).

0 Kudos
RyanDeBruyn1
New Contributor III

Thanks!   This was a GP widget added in WAB online when configuring the web app, so not using WAB Developer directly for widgets.  I was thinking might be able to do something similar since the messages are being cleared when task is complete...  but most likely limited with the defaults. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ryan,

   If you are using AGOL WAB app then there is nothing you can do.

AhnaMiller2
Occasional Contributor

Ryan, I found a work around to help with this if you are doing it in an out of the box GP widget. . Let me know if you are still needing help with this

0 Kudos
RyanDeBruyn1
New Contributor III

Ahna that's awesome yes. Just using out of the box online gp widget from web app builder. Would love it if my messages remained in the dialog after execution.

Let me know if you can.

Much thanks!!!

-Ryan

Get Outlook for iOS<https://aka.ms/o0ukef>

0 Kudos