Logic apps replace "null" with "" or vica versa - azure-logic-apps

I'm trying to compare the data in dataverse with a Excel file to see whether the dataverse rows needs to be updated or not.
I'm using compose on each item from dataverse and a combination of compose, json parse and select to create two output values that I can compare to see if they match or not. I have to do this because as far as I can tell Logic Apps has no sane way of comparing data otherwise.
The outputs are working as intended the only problem is that fields with no value from dataverse show up as "name": "null" and the Excel data with no value shows up as "name": "" which causes my compare to fail.
Is there any to easily replace all "null" or "" with either "" or "null"?
Dataverse "output" example
[
{
"name": "john"
"last": "doe"
"address": "null"
}
]
Excel "output" example
[
{
"name": "john"
"last": "doe"
"address": ""
}
]
The actual data has many more fields so I would prefer to somehow just look over the whole "output" and match anything that is either "" or "null" and replace it with something and not go over every possible field one by one.

I found a "solution".
if(empty(items('myAction')?['myActionField']), '', items('myAction')?['myActionField'])
This checks if the field is empty or not. If its empty, the value '' is assigned thus creating a (empty) string type field. If its not empty, the original value is applied.
The downside is that this cannot possible be very efficient and you have to do this for every field so if you have a lot of fields it takes a lot of time. In my case I "only" have 30 or so so its still somewhat manageable.
A better way would be if you could just loop over a "value" array and remove/convert all null values in one go. Or create a mapping that tells logic apps what field type a field so be. But I don't know if that is possible.

As you are using a Compose action anyway, instead of getting a dynamic content for your address field directly, you can just use the if and equals functions in an expression, something like if(equals(__your_source_field__, 'null'), '', __your_source_field__).
Then the output of the Compose action won't have "null" values, and you can proceed with comparison as requried.

Logic Apps support a lot of expressions. One set of expressions they support are String functions. And one of those functions is Replace(text, oldText, newText).
If the value you're trying to replace is an actual string holding "null" as its value, try this expression to replace null with an empty string:
replace(output, 'null', '')
Logic Apps string functions

Related

Querying a SQL table column that contains JSON and updating a value in that JSON based on a condition

This table has about 1.5 million rows. A particular column contains JSON. What I need to do is query that column for that JSON and then query for a particular boolean key/pair "FLAG" in that JSON. If that "FLAG" is True, I'll need to update another key/pair in that JSON to a Null value rather than the string that it currently is.
The tricksy part of this for me is that I have to query the JSON itself and run the check. But it's not like I can index the JSON like in other languages, it's effectively a string that I'm going to need to query via sql-regex. I'm also a bit confused as to how I will surgically update the second key/pair to a null.
Json Start:
{
"flag": true,
"anotherKvP": "some string"
}
How I need the Json to be updated to:
{
"flag": true
"anotherKvP": null
}
So I ended up coming across a function called STUFF ( character_expression , start , length , replaceWith_expression ) which allowed me to jam together a string within a string. That's the second part.
The first part, in my FROM clause, I selected the value's index I needed to split on using PATINDEX ( '%pattern%' , expression ) to gather the starting index of the patterned position.
Lastly, the WHERE and LIKE was used to pattern match the query for the "flag": true.

how to get php multiple result sets object into Extjs store?

sql server stored procedure returns multiple result sets into php where I am formatting into a 2 dim array so as to get results returned as single object for extjs store callback.
sets[[{"field1": 1, "field2": 2}], [{"field3": 3, "field4": 4}]]
Cannot find any examples of how the extjs.store.proxy.reader can handle this. These result sets are not associated so do not think the associated model stuff will help. I can obviously format the php return var anyway, but thought a single array containing the multiple result sets would be a good start. We have single result sets working fine by specifying correct rootProperty in store.

select first two characters of values in a concatenated string

I am trying to create a formula field that checks a string that is a series of concatenated values separated by a comma. I want to check the first two characters of each comma separated value in the string. For example, the string pattern could be: abcd,efgh,ijkl,mnop,qrst,uvwx
In my formula I'd like to check if the first two characters are 'ab','ef'
If so, I would return true, else false.
Thanks.
To do this properly, you need to use a regular expression. Unfortunately the REGEX function is not available in formula fields. It is, however, available in formulas in Validation Rules and in Workflow Rules. You can, therefore, specify the below formula in either of a Validation or Workflow Rule:
OR(
AND(
NOT(
BEGINS( KXENDev__Languages__c, "ab" )
),
NOT(
BEGINS( KXENDev__Languages__c, "ef" )
)
),
REGEX( KXENDev__Languages__c , ".*,(?!ab|ef).*")
)
If it's a Validation Rule, you're done -- this formula will create an error if any of the entries do not start with "ab" or "ef". If it's a Workflow Rule, then you can add a Field Update to it to update some field with False when this formula is true (if this formula is true then there is at least one item that doesn't start with ab or ef, so that would make your field False).
Some may ask "What's with the BEGINS statements? Couldn't you have done this all with one REGEX?" Yes, I probably could, but that makes for an increasingly complex REGEX statement, and these are quite difficult to debug in Salesforce.com, so I prefer to keep my REGEXes in Salesforce.com as simple as possible.
I suggest you to search for ',ab' and ',ef' using CONTAINS method. But first of all you need to re implement method which composes this string so it puts ',' before first substring. At the end returned string should look like ',abcd,efgh,ijkl,mnop,qrst,uvwx'.
If you are not able to re implement method which compose this string use LEFT([our string goes here],2) method to check first two chars.

How to use NSPredicate with NSPredicateEditor on different data (Multiple Predicates?)

I've got an array of filepaths and I've got a NSPredicateEditor setup in my UI where the user can combine a NSPredicate to find a file. He should be able to filter by name, type, size and date.
There are several problems I have now:
I can only get one predicate object from the editor. When I use
"predicateForRow:" it returns (null)
If the user wants to filter the file by name AND size or date, I
can't just use this predicate on my array anymore because those
information are not contained in it
Can I split up a predicate into different predicates without
converting it into a NSString object, then search for every #" OR " |
#" AND " and seperating the components into an array and then
converting every NSString into a new predicate?
In the NSPredicateEditor settings I've some options for the "left Expression":
Keypaths, Constant Values, Strings, Integer Numbers, Floating Point Numbers and Dates. I want to display a dropdown menu to the user with "name", "type", "date", "size". But then the generated predicate automatically looks like this:
"name" MATCHES[c] "nameTest" OR "type" MATCHES[c] "jpg" OR size == 100
Because the array is filled with strings, a search for "name", "type" etc. and those strings do not respond to #"myString"*.name*m the filter always returns 0 objects. Is there a way to show the Name, Type, Size and Date in the Menu, but write "self" into the predicate without doing it by hand?
I've already searched in the official Apple tutorials, on Stackoverflow, Google, and even Youtube to find a clue. This problem troubles me for almost one week now. Thanks for you time! If you need more information please let me know!
You have come to the right place! :)
I can only get one predicate object from the editor.
Correct. It is an NSPredicateEditor, not an NSPredicatesEditor. ;)
When I use "predicateForRow:" it returns (null)
I'm not sure I would use that method. My general rule of thumb is to largely ignore that NSPredicateEditor is a subclass of NSRuleEditor, mainly because it's such a highly specialized subclass that many of the superclass methods don't make that much sense on a predicate editor (like all the stuff about criteria, row selection, etc). It's possible that they're somehow relevant, but if they are, I haven't figured out how yet.
To get the predicate from the editor, you do:
NSPredicate *predicate = [myPredicateEditor objectValue];
If the user wants to filter the file by name AND size or date
You mean (name = [something]) AND (size = [something] OR date = [something])?
If so, NSPredicateEditor can do that if you've set the nesting mode to "Compound".
I can't just use this predicate on my array anymore because those information are not contained in it
What information do you need?
Can I split up a predicate into different predicates without converting it into a NSString object, then search for every #" OR " | #" AND " and seperating the components into an array and then converting every NSString into a new predicate?
Yes, but that is a BAD idea. It's bad because NSPredicate already contains all the information you need, and converting it to a different format and doing string manipulations just isn't necessary and can potentially lead to complications (like if someone can type in a value for "name", what happens if they type in " OR "?).
I'm having a hard time trying to figure out what it is you're trying to do. It sounds like you have an array of NSString objects that you want to filter based on a predicate that the user creates? If so, then what do these name, date, and size key paths mean? What are you trying to do?

Conditional printing depending of empty or null value in Crystal Reports

Suppose I have an StoredProcedure that returns a unique row corresponding to a table with columns "Name" and "Surname".
I want the report to show:
Name: NameField
Surname: SurnameField
Where the "NameField" and "SurnameField" are the fields returned by the StoredProcedure.
The special requirement, is that if "SurnameField" is empty or null, then I don't want to show the "Surname: SurnameField".
How can I achieve this?
The only thing that I thought is breaking the storedprocedure in two, one for Name and one for Surname, and dividing each line in different subreports and selecting "Delete if empty" (or something like that) for the second... but this is really overkill, I guess there's an easier way.
Should be quite a few ways of achieving this. I'm not quite sure how your report is laid out but you can surpress the field and label or entire section (if it has it's own) using a simple formula; isnull({table.field}) or {table.field} = ''
Or if you have set nulls to be treated as defaults rather than exceptions you can simply do: {table.field} = ''
L
Set the field > 1 (assuming all is greater than 1 already) or <> 0.
That should filter out records with a blank in that area.
You can achieve it by Section Expert:
Supposing the name field name is Surname and the table is NAME and the field storing the value of surname is S_NAME_VALUE. You can put up the filter checking if the value is NULL or BLANK.
if {NAME.SURNAME} in ['SNAME'] and
{NAME.S_NAME_VALUE} =''
then
TRUE
I am assuming there are some codes for Surname filtering i.e SNAME.
If not you can use the one condition and mark it as true.
if {NAME.S_NAME_VALUE} = '' then TRUE

Resources