XML Expression Binding - Proceed Code in conditional operator - sapui5

I am currently working on a Fiori app. At the moment I try to set a title depending on the value of a property I get from my OData service. Therefore I want to use expression binding with the conditional operator.
So when ${PROPERTIY} has the value "EXAMPLE", it should print the value of OUTPUT_PROPERTY_1. Otherwise, it should print the value of OUTPUT_PROPERTY_2.
XML:
<ObjectListItem title="{= ${PROPERTIY} === 'EXAMPLE' ? '${OUTPUT_PROPERTY_1}' : '${OUTPUT_PROPERTY_2}'}">
Unfortunately, it just prints ${OUTPUT_PROPERTY_1} or ${OUTPUT_PROPERTY_2}, and does not proceed the code to get the actual value of the properties.
Is there any chance to solve this problem or even a good workaround in order to print the actual value of the related property?

Remove the apostrophes around the expression binding syntax:
title="{= ${PROPERTIY} === 'EXAMPLE' ? ${OUTPUT_PROPERTY_1} : ${OUTPUT_PROPERTY_2}}"
Otherwise, '${OUTPUT_PROPERTY_x}' will be treated as a string literal.

Related

Data factory lookup (dot) in the item() name

I am having lookup wherein salesforce query is there. I am using elements (item()) in subsequent activities. Till now i had item().name or item().email but now i have item().NVMStatsSF__Related_Lead__r.FirstName which has (dot) in the field name.
How should i parse it through body tag so that it reads it correctly?
So I have the following data in item()
{
"NVMStatsSF__Related_Lead__c": "00QE000egrtgrAK",
"NVMStatsSF__Agent__r.Name": "ABC",
"NVMStatsSF__Related_Lead__r.Email": "geggegg#gmail.com",
"NVMStatsSF__Related_Lead__r.FirstName": "ABC",
"NVMStatsSF__Related_Lead__r.OwnerId": "0025434535IIAW"
}
now when i use item().NVMStatsSF__Agent__r.Name it will not parse because of (dot) after NVMStatsSF__Agent__r. And it is giving me the following error.
'item().NVMStatsSF__Related_Lead__r.Email' cannot be evaluated because property 'NVMStatsSF__Related_Lead__r' doesn't exist, available properties are 'NVMStatsSF__Related_Lead__c, NVMStatsSF__Agent__r.Name, NVMStatsSF__Related_Lead__r.Email, NVMStatsSF__Related_Lead__r.FirstName, NVMStatsSF__Related_Lead__r.OwnerId'.",
"failureType": "UserError",
"target": "WebActivityToAddPerson"
this is because ADF uses '.' for object reading.
Could you find a way to rename the field name which contains '.'?
Seems like you need a built-in function to get the value of an object according to the key. Like getValue(item(), 'key.nestkey'). But unfortunately, seems there isn't such a function. You may need handle your key first.
Finally, it worked. I was being silly.
Instead of taking the value from the child table with the help of (dot) operator I just used subquery. Silly see.
And it worked.

Using where() node to filter empty tags in Kapacitor

Using Kapacitor 1.3 and I am trying to use the following where node to keep measurements with an empty tag. Nothing is passing through and I get the same result with ==''.
| where(lambda: 'process-cpu__process-name' =~ /^$/)
I can workaround this issue using a default value for missing tags and filter on this default tag, in the following node but I am wondering if there is a better way structure the initial where statement and avoid an extra node.
| default()
.tag('process-cpu__process-name','system')
| where(lambda: \"process-cpu__process-name\" == 'system' )
Sure it doesn't pass, 'cause this
'process-cpu__process-name'
is a string literal it TICKScript, not a reference to a field, which is
"process-cpu__process-name"
You obviously got the condition always false in this case.
Quite common mistake though, especially for someone with previous experience with the languages that tolerates both single & double quote for mere string. :-)
Also, there's a function in TICKScript lambda called strLength(), find the doc here, please.

Compare String using tMap

I am using Talend to prepare dataware.
I want to compare the string with the contents of a column using the tMap component and create a variable to store in the DB. The problem is that the == operator does not give the right result (Example: row2.recipient == "text"?"text":"" I always get "") and if I use .equals I get errors when executing.
You will get error if row2.recipient is null, and "==" should not be used when comparing strings.
Correct syntax would be :
"text".equals(row2.recipient)?"text":""
Then you will prevent NullPointerExceptions.

How to set variable value after "Print when Expression" from textfield returned true

Using iReport I have a textfield with following "Print When Expression":
new Boolean($F{data}.doubleValue()<3 && $V{check}.intValue()==0);
My problem is that I only want to print this textfield once. For that I thought I can use a variable (check).
I tried to use this expression for the variable:
($F{data}.doubleValue()<3) ? 1 : 0
The problem is that the expression for the variable is called before the textfield checks its "print condition" and so the textfield never get printed.
How can I achieve that the variable value is set AFTER the textfield "print condition" returned true?
I want to mark the first value which is smaller than a reference value
I often use the parameter map (P{REPORT_PARAMETERS_MAP}) to store and evaluate custom expression depending on previous values and outputs
Example (return true if value $F{X}<100 and it has never been below before)
<printWhenExpression>
<![CDATA[$F{X}.doubleValue()<100?$P{REPORT_PARAMETERS_MAP}.put("X_LESS_100",true)==null?true:false:false]]>
</printWhenExpression>
This expression leverage the fact that Map.put(K,V) returns the previous value associated with key, that is null if never called, while second time $F{X} is below 100 it will return our previous set value that is true.
Note: you do not need to define any variable.
I found a workaround, but I don't find it a very good way, because my solution is related to the evaluation time of the conditions from the textfield and the variable.
So if anybody has a nice solution please post it.
I set the initial value of my check variable to 0.
The variable expression looks like this:
($F{data}.doubleValue() >= 3)? 0 : ($F{data}.doubleValue() < 3 && $V{check}.intValue()==0) ? 2 : 1;
The "Print When Expression" from the textfield is:
new Boolean($V{check}.intValue()==2);

Parse setting explicit type using REST

I know you can set a Date field explicitly like so:
"date_brewed":{
"__type":"Date",
"iso":"2009-10-15T00:00:00.000Z"
}
But is there anyway to explicitly set the column type of 'Number' using REST? For instance, I'd like to set the column 'batch_size' to a Number instead of a string but when POST'ing via rest it keeps getting created as a string type column.
Meh, this was more of a Perl issue than a Parse issue.
What I had to do to tell Perl to treat the number like an actual number was to add a zero to the value. :/