• Martin Lorenz
    December 19, 2016 at 12:07 am #3315

    Hello guys.

    I would like to ask if it is possible add alert (alert control) from script. Ok, when I add alert at one of the events (e.g. on change, on load … ) it works. But I want to add an alert message in the script.

    Martin Lorenz
    December 19, 2016 at 3:06 am #3317

    I tried something like this:

    if(tw.local.myVariables ==””) {

    this.context.getSubview(“Alerts1”)[0].appendAlert(“”, “Message”)

    }

    but unfortunately did’t work.

    SPARK Support
    December 19, 2016 at 11:06 am #3321

    Hi Martin,

    Where are you placing this alert code?  In the Inline JavaScript?  Or are you adding a file in Included Scripts?

    Regards,

    Stephen P.

    Martin Lorenz
    December 19, 2016 at 11:21 am #3322

    Hello.

    Thanks for answer. I would call alert in function which is in js faile (server file).

    SPARK Support
    December 19, 2016 at 11:42 am #3323

    Hi Martin,

    If you are including a JavaScript file, then you will be unable to access variables through tw.local.

    Standard JS methods will work such as alert() and console.log():

    somePublicFunction function(arguments) {

    alert(“We are doing something in the code here”);

    console.log(argument1);

    },

     

    Regards,

    Stephen P.

    Martin Lorenz
    December 19, 2016 at 12:19 pm #3324

    Ok, and when I’ll do as you wrote, alert will be show in Spark control Alert?

    SPARK Support
    December 19, 2016 at 12:43 pm #3326

    Hi Martin,

    You may want to review this article on Creating Your Own Control as it reviews in detail how the Inline JavaScript, Included Scripts and events are connected.

    Regards,

    Stephen P.

    Martin Lorenz
    December 19, 2016 at 1:00 pm #3327

    I understand that can’t call custom control spark Alert with external script? I want to do something like this: write in server script copmponent, script, which will validate form and when some condition isn’t fulfilled, I would call alert control with message for user.

    SPARK Support
    December 19, 2016 at 1:32 pm #3328

    Hi Martin,

    Please see this article Validation With SPARK.

    Regards,

    Stephen P.

    Saroj Panda
    January 19, 2017 at 1:58 am #3516

    Hi Martin,

    How did you solve your requirement? Are you able to use the Alert control to show the validation messages computed in server script?

     

    Hello Stephen,

    Any option on supporting the use case explained by Martin. The Validation with SPARK is more about control level validation which need to be written in coach controls of in custom HTML in coach.

     

    Regards,

    Saroj

    SPARK Support
    January 23, 2017 at 4:12 pm #3541

    Hi Saroj,

    The issue here is the mixture of server variables and calling the Alert control at run-time.  The way that I would work around this is to evaluate some variable, say tw.local.testDec.  If the value is greater than > 50.5, then set Boolean tw.local.testBool = true.

    A Data control can be bound to the Boolean, and from the run-time JavasScript, page.ui.get(“Data_Control1”).getData() can be used to evaluate true or false.  Or better yet. bind a data control to tw.local.testDec, use getData() to retrieve the value and process whatever decision is needed.

    Regards,

    Stephen P.

    Saroj Panda
    January 24, 2017 at 12:27 am #3551

    Agree with the approach. I guess this is the same approach to do page level validation using default BPM controls too.

    Additional, to stop navigation use the decision gateway after the evaluation script and check the defined control variable. If true then wire back to coach else continue to next flow. In coach the script will take care of showing the Alert 🙂

     

    Regards,

    Saroj

    SPARK Support
    January 24, 2017 at 3:28 pm #3562

    Hi Saroj,

    Thank you for the added detail.

    Regards,

    Stephen P.

    Duane Steffens
    June 9, 2017 at 6:34 am #4376

    Stephen,

    In the above article that you referenced, it says you can control validation with a server side script by using this command:

    if (tw.local.validateText == “”) {

    tw.system.addCoachValidationError (tw.system.coachValidation, <span class=”wysiwyg-color-cyan130″>”tw.local.validateText”</span>, <span class=”wysiwyg-color-cyan130″>”Enter some text! (Server Side)”</span>);

    Is there a similar command for server side scripts that will add an alert message?   Or do I need to follow the steps above adding a data control, etc.

    Thanks!

    SPARK Support
    June 9, 2017 at 2:10 pm #4378

    Hi Duane,

    When you say add an alert message, are you referring to the Validation text?  Or as in an Alerts control?

    https://salientprocess.zendesk.com/hc/en-us/articles/217604528-Alerts

    You may also want to take a look at the RedBook Deliver Modern UI for IBM BPM with the Coach Framework and Other Approaches. There is a section on Validation for SPARK starting on page 179.

    The point about using Data controls is that they can provide a vehicle for access to tw.local variables at the coach level, whether using the values for validation or otherwise.  Part of the power of SPARK is the ability to incorporate validation into the control events directly within the coach.

    Regards,

    Stephen P.

    SPARK Support
    June 9, 2017 at 2:12 pm #4379

    Hi Duane,

    Also, please keep in mind that as an Enterprise Subscriber,  you have access to the Submit A Ticket resource located under the Get Help menu.

    Please use our ticketing system if you would like to provide more information about your particular use case, or submit a sample TWX containing the scenario.

    Regards,

    Stephen P.

Viewing 16 posts - 1 through 16 (of 16 total)

You must be logged in to reply to this topic.

Start typing and press Enter to search