Search Support
-
Martin LorenzDecember 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 LorenzDecember 19, 2016 at 3:06 am #3317I tried something like this:
if(tw.local.myVariables ==””) {
this.context.getSubview(“Alerts1”)[0].appendAlert(“”, “Message”)
}
but unfortunately did’t work.
SPARK SupportDecember 19, 2016 at 11:06 am #3321Hi 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 LorenzDecember 19, 2016 at 11:21 am #3322Hello.
Thanks for answer. I would call alert in function which is in js faile (server file).
SPARK SupportDecember 19, 2016 at 11:42 am #3323Hi 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 LorenzDecember 19, 2016 at 12:19 pm #3324Ok, and when I’ll do as you wrote, alert will be show in Spark control Alert?
SPARK SupportDecember 19, 2016 at 12:43 pm #3326Hi 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 LorenzDecember 19, 2016 at 1:00 pm #3327I 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 SupportDecember 19, 2016 at 1:32 pm #3328Hi Martin,
Please see this article Validation With SPARK.
Regards,
Stephen P.
Saroj PandaJanuary 19, 2017 at 1:58 am #3516Hi 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 SupportJanuary 23, 2017 at 4:12 pm #3541Hi 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 PandaJanuary 24, 2017 at 12:27 am #3551Agree 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 SupportJanuary 24, 2017 at 3:28 pm #3562Hi Saroj,
Thank you for the added detail.
Regards,
Stephen P.
Duane SteffensJune 9, 2017 at 6:34 am #4376Stephen,
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 SupportJune 9, 2017 at 2:10 pm #4378Hi 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 SupportJune 9, 2017 at 2:12 pm #4379Hi 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.
-
|
You must be logged in to reply to this topic.