cancel
Showing results for 
Search instead for 
Did you mean: 

Personas 2 Scripting: Creating Alert Dialogues

Former Member
0 Kudos

Hi,

I want to introduce a decision dialogue into my script - pop-up box with 'Do you want want to do X?" - Yes or No reply. The script picks up the response and carries on as appropriate.

I found this KB article by Clemens Gantert & Tamas Hoznek - https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=393320781 which seems to suggest that this is possible.... "This article describes how to create alerts and confirmation dialogs in Personas Scripting with the method session.utils.showOptionDialog()."

I'm a total novice when it comes to JavaScript so please forgive my naivety here but I assumed that if I stuck the code snippets into a Personas Script that contained just one ‘Calculate in JavaScript’ line, I would get the dialogue box described in the article and I could build up from there but that one line is giving me a script error – ‘JavaScript Error’.

Can anyone get me on the right track please?

Regards.

Patrick.

Accepted Solutions (1)

Accepted Solutions (1)

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

The KB article is for Personas 3.0 and this won't work in 2.0

You could do something like this in a JavaScript step in 2.0 and it works. Not sure if this will be enough for what you want to achieve, but it's a start:

if (confirm('Are you sure you want to continue?')) {

    alert("yes");

} else {

    alert("no");

}

However this will restrict you to stay in the JavaScript step for further actions after the decision, and it is not able to control further steps in your Personas script. Also, your options are restricted to 'Yes' or Cancel'.

Edit: Actually, there is a way to use this to control the Personas script.

Do this:

In the JS step, use this code:

if (confirm('Are you sure you want to continue?')) {

    args.reply = 'Yes';

} else {

    args.reply = 'No';

}

Then, in the next Personas script step, you will be able to use the value of variable reply. You can copy it into another field, use it as a variable in an IF statement etc.

Message was edited by: Tamas Hoznek

Former Member
0 Kudos

Thank you very much Tamas - it works like a charm - perfect.

Regards.

Patrick.

Answers (1)

Answers (1)

former_member105930
Active Participant
0 Kudos

I had a similar issue, and in the end I simply created my own alert box like this which consists of a group box , a label and two script buttons. This Group box was then hidden.

The two different buttons would then invoke different scripts depending on which one is pressed. So if Proceed was selected, it would contain all the relevant scripting to continue the process. If cancel was selected, then the process would stop.

The first step of each individual script on these buttons would Hide the Group box again.

So in my previous script, where I got to the point I wanted the the alert to appear I would simply have the last action in the script unhide the Hidden Control which would be this group box.

I agree this is not as simple as the JavaScript option suggested by Tamas, but it does work.

Kind regards,

Ian

Former Member
0 Kudos

Hi Ian, this is a very resourceful solution and has given me a few ideas about other screen design issues I have been wrestling with but for this particular problem, Tamas's suggestion is just what I needed.

Many thinks for taking the time to reply and sharing your experience - it was much appreciated.

Regards.

Patrick.