Conditional LIRU for script?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
JonP
Posts: 287
Joined: Thu Feb 16, 2017 9:49 pm
Location: United States

Conditional LIRU for script?

Post by JonP »

I tried to do this in the render script of a form cell, but AIM just ignored the SECTION condition and ran the script regardless:

Code: Select all

<<IF LoggedInPerson.Role.Strategy='No Visibility' THEN SHOW_SECTION>>
var divsToHide = document.getElementsByClassName("ChangeStrategies");

    for(var i = 0; i < divsToHide.length; i++)
    {
    divsToHide[i].style.visibility="hidden";
    }
<<END_SECTION>>
Is there a way to add a conditional based on an LIRU attribute inside Javascript?
v8.1 on Windows 10 / MySQL 5.6 (local), v8.1 on Windows Server 2016 / MySQL 5.6 (server)
Jaymer
Posts: 2528
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Conditional LIRU for script?

Post by Jaymer »

1) check ServerOutput log and see if there's a msg about not being able to resolve LoggedInPerson.Role.Strategy
2) is Strategy a shortcut?
3) the command is SHOW_SECTION START
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
JonP
Posts: 287
Joined: Thu Feb 16, 2017 9:49 pm
Location: United States

Re: Conditional LIRU for script?

Post by JonP »

:oops: Face-palm. And I've written slight variations on that line dozens of times for HTML cells. My lame excuse (because I feel a need to provide one) is that I threw my back out the other day and the pain distracted me.

I fixed it to "SHOW SECTION_START" and same problem. Role is a single peer reference attribute and Strategy is a plain text attribute. Tomcat gives me this:

Code: Select all

Unable to process tag expression IF LoggedInPerson.Role.Strategy='No Visibility' THEN SHOW SECTION_START
Unable to resolve attributes when calculating expression END_SECTION
My guess is that the script feature doesn't support tag expressions.
v8.1 on Windows 10 / MySQL 5.6 (local), v8.1 on Windows Server 2016 / MySQL 5.6 (server)
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Conditional LIRU for script?

Post by tford »

IF LoggedInPerson.Role.Strategy
1) Have you tried shortcutting Strategy into LoggedInPerson and referring to it in your IF?

2) Have you tried just using some Plain Text LoggedInPerson attribute to keep the test as simple as possible?
Tom - V8.8 build 3137 - MySql / PostGres
UnionSystems
Posts: 197
Joined: Fri Jun 17, 2016 7:10 am
Location: Brisbane Australia
Contact:

Re: Conditional LIRU for script?

Post by UnionSystems »

JonP wrote:I tried to do this in the render script of a form cell, but AIM just ignored the SECTION condition and ran the script regardless:

Code: Select all

<<IF LoggedInPerson.Role.Strategy='No Visibility' THEN SHOW_SECTION>>
var divsToHide = document.getElementsByClassName("ChangeStrategies");

    for(var i = 0; i < divsToHide.length; i++)
    {
    divsToHide[i].style.visibility="hidden";
    }
<<END_SECTION>>
Is there a way to add a conditional based on an LIRU attribute inside Javascript?
You say "render script of a form cell" but I can only find "Initialization" scripts on form cells? If you mean the render script on a "form" try this as your render script

Code: Select all

if "<<LoggedInPerson.Role.Strategy>>"=="No Visibility" {
var divsToHide = document.getElementsByClassName("ChangeStrategies");
    for(var i = 0; i < divsToHide.length; i++)
    {
    divsToHide[i].style.visibility="hidden";
    }
}
AWS Linux, Windows Server, AIM 8.4 & 8.6
JonP
Posts: 287
Joined: Thu Feb 16, 2017 9:49 pm
Location: United States

Re: Conditional LIRU for script?

Post by JonP »

Dave, you're awesome! I did need to make a slight adjustment to the if statement to include parentheses:

Code: Select all

if ("<<LoggedInPerson.Role.Strategy>>"=="No Visibility") {
and then it worked like a charm. I'm going to start using render script more for this sort of thing now that I know how.

And yes, it is a form cell render script. I may have a different version than you.
v8.1 on Windows 10 / MySQL 5.6 (local), v8.1 on Windows Server 2016 / MySQL 5.6 (server)
Jaymer
Posts: 2528
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

and this...

Post by Jaymer »

divsToHide.addClass("w3-blue")

Instead of hiding them, this would ADD a style to them. Could be handy. Nice tip Dave.

http://api.jquery.com/addClass/
Last edited by Jaymer on Thu Aug 02, 2018 6:38 pm, edited 1 time in total.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
JonP
Posts: 287
Joined: Thu Feb 16, 2017 9:49 pm
Location: United States

Re: Conditional LIRU for script?

Post by JonP »

Good to know! Thanks, Jaymer.
v8.1 on Windows 10 / MySQL 5.6 (local), v8.1 on Windows Server 2016 / MySQL 5.6 (server)
Post Reply