Question

Highlighting a row thru Inline style - how to check if property has a value

Hi Team,

We have a section displaying a table. The table has it's columns dynamically sourced thru a report. In our application we also have two properties for a price field - numeric and text.

We are working on a requirement to highlight the rows which have only text price listed and no numeric price.

In similiar community post I found that we can use the below as inline style for the section:

<%=tools.getProperty(".pyID").getStringValue().startsWith("DXC") ? "background-color: red;" : "" %>

to highlight the specific row that has case ID starting with DXC, for example.

What method can I use to see if a property has a value or not? I need the activity to check if .NumericPrice property has a value in pyWorkPage for the specific item.

Kind Regards,

Petar Hr.

***Edited by Moderator: Lochan to update platform capability tags***

Correct Answer
July 17, 2019 - 10:33am

Hi Fahad, All, 

After couple of attempts and the assistance of an LSA we've managed to get this requirements to work. Here are the full details for future reference: 

Need: Highlight a row in a table, based on a When condition (for example property is missing a value). The table source is a report definition.

Steps

Step 1. Apply the below inline style on the row:

<pega:when name="WhenConditionToBeChecked"> color:red; </pega:when>

where WhenConditionToBeChecked is your When rule. Be sure that the section, when rule and report definition are in the same class.

Step 2. The property from the When condition should be present in the report definition. In my case the property NumericPrice needed to be added into the report definition with the option for the column to be hidden. This way the information was extracted from the report, it is used in the background from the When rule and the column is not displayed in the final view, keeping the UI as per the initial requirements. 

Step 3. Justify the use of this inline style (with the full conscience that inline styles are not recommended as per the guardrails).

This thread can be now marked as resolved/completed. 

Cheers!

Kind Regards, 

Petar Hr.

Comments

Keep up to date on this post and subscribe to comments

July 10, 2019 - 10:33am

Hi Petar

You can use the below code to highlight entire row using inline styles:
"[pega:when name="WhenName"]color:red;[/pega:when]"

Replace all "[" with "<" and replace all "]" with ">"

Add your property in the when rule. You can add this code to the ROW properties in the table.
you can add more styles in the above code seperated by ";".

Note: use of inline styles is no longer recommended

July 10, 2019 - 10:35am

Hi Fahan, 

Thank for the reply. 

Can you please elaborate on what when rule are you referring to? 

Also, if inline styles is not recommended, what is the best approach to have a row in a section conditionally highlighted when the property .NumericPrice is missing? 

We are using Pega 8.2.2 btw. 

Kind Regards, 

Petar Hr.

July 11, 2019 - 3:28am

Hi Petar

By when rule I mean, any when rule. Create a when rule and add your property check in the when rule. For your case in the when rule use expression "Property ".NumericPrice" exists and has a value" . When this is false, your row will be highlighted.

Acheiving this without inline style is a little complicated.
-you need to add a CSS class on your table under presentation tab.
-Then add a html section in your current section.
-run an onload JS fucntion in the html section which will add a css class to you table if your conditions are met.

using inline style is pretty simple.

July 11, 2019 - 6:59am

Hi Fahad, 

Thanks for the clarifications! It's clear now. 

 

The issue I have with the implementation of the When rule is that it does not check the specific CaseID and as a result it highlights all the rows.

 

I have a When rule that checks if .NumericPrice is empty. It is saved in my class (class name Example-Work-App1).

 

The section is also saved in the same class. Both section and when rule are in the higher unlocked RS version.

 

When I apply inner style with the above snippet ( <% /pega:when name="WhenName" %> color:red; <% /pega:when %>) it highlights all of the rows and not the ones that have .NumericPrice without a value.

 

When I run the When rule on the thread of a specific Case ID, it works fine. So, I think the When rule is not executed in the correct context. What do you think?

 

I'm attaching screenshots from my development so far, hope that brings clarification on what I'm doing wrong.

 

P.S. I'm refactoring old activities in the app, so please note that the naming of the When rule is not properly set for now. I will fix that once I get a working example in my private edit. :) 

 

Kind Regards,
Petar Hr.

July 11, 2019 - 7:36am

Hi Peter

The above mentioned code is a JSP tag, its not pega, hence giving "!WhenRule" will not work. You have to give the when rule name in double qoutes without "!" and handle the "!" Not condition in when rule.
I have attached the screenshot. Try configuring your when rule in this manner.

July 11, 2019 - 9:10am

Thanks Fahad, 

 

I changed the rule as per your suggestion, however all of the lines in the section are being colored. 

 

​I think the rule is not taking the context for each Case Id thru it's pyWorkPage and it's running in a blank page, which makes it by default to "think" .NumericPrice is empty. 

 

What do you think?

July 11, 2019 - 11:59am

Hi Petar

Seeing your screenshot , I realised you have added the Inline style on coulmn properties. Thats wrong. You need to add this condition on ROW properties. Keeping it on coulmn will not have the right page context.
If you keep it on Row, the when condition will run in context of each page of the page list. So you property should be in the context of each page of the pagelist.

July 17, 2019 - 10:33am

Hi Fahad, All, 

After couple of attempts and the assistance of an LSA we've managed to get this requirements to work. Here are the full details for future reference: 

Need: Highlight a row in a table, based on a When condition (for example property is missing a value). The table source is a report definition.

Steps

Step 1. Apply the below inline style on the row:

<pega:when name="WhenConditionToBeChecked"> color:red; </pega:when>

where WhenConditionToBeChecked is your When rule. Be sure that the section, when rule and report definition are in the same class.

Step 2. The property from the When condition should be present in the report definition. In my case the property NumericPrice needed to be added into the report definition with the option for the column to be hidden. This way the information was extracted from the report, it is used in the background from the When rule and the column is not displayed in the final view, keeping the UI as per the initial requirements. 

Step 3. Justify the use of this inline style (with the full conscience that inline styles are not recommended as per the guardrails).

This thread can be now marked as resolved/completed. 

Cheers!

Kind Regards, 

Petar Hr.