I have found a better way of mapping while checking for null values. I used to branch on the field I was mapping. Then I would check to see if it was null. If it was I would not map it. If it wasn’t then I would map it. This took several steps thereby increasing the amount of time for processing. This is the simple way of doing it. When you map the field from the input tab to the output tab, right click on the black line that appears between the two fields you just mapped. Right click on the line and select “properties”. Then a little window will appear with the following text near the top “copy only if”. There will be a little box in front of it which you click on. Once you do, then the box under the line will turn from gray to white (which means you can edit it). Inside of the text box type the name of the field you want to check to see if it is null. NOTE that the field needs to be placed between percent signs. Here is an example if the name of the field was “VARNAME”. Then you would type " %VARNAME% " in the text box. Then you would click “OKAY”. The black line should now be blue. The good part about this is that you don’t have to specify the field you are mapping in the text box. You could specify another field name if you only wanted to map this if another field was not null. Also, if you are mapping a field inside of a record structure than you would give the full path of the record structure. Let me know if you any questions about this method.
That is cool. I have been using the Link properties features for other conditional mapping, but not yet for checking null values. That was a nice eifficient way of checking for null values, especially since we do that most often in so many maps.
You might find the following useful as well.
Using regular expressions can greatly simplify your BRANCH constructs. The regular expression appendix in the B2B Integrator Guide describes the syntax. The regular expression in a label must be surrounded with slashes. A couple of examples:
Tests for one or more characters. Strings that are $null or are empty will not be selected by this label (e.g. the branch won’t take this path)
Tests that the string starts with the characters “ISA”.
BRANCH on ‘/tailOfAK5’
/.+/: MAP (tailOfAK5 has one or more chars)
$default: SEQUENCE (tailOfAK5 is empty or null)
I do have a record structure and I need to map only the fields which are not null. So in order to do the conditional mapping, I have copied the element name and pasted it on the property window
(%TestInputRecordRef/dna/PRODUCT/ATR_UPC%) as mentioned in first post.
And this did not work.
Any help would be highly appreciated.
There is a service called isNullorBlank in the WmEDI package. This can be used to find out whether the varible is null or blank.
Should’nt I be able to do conditional mapping as explained by Patel in this thread. If so how do I do it. I am not using EDI document.It is a canonical data being mapped from input record reference to output record reference.
I did right click the map line and at the properties window ,checked in “copy only if” and tried following values
%ATR_UPC% != null
Any help on this would be greatly appreciated.
You are right, this should work the way you have it. All you really need to verify is the path to the field that you are checking for null in “the copy only if” field. You don’t need “!= null”
IF you are looping over any section in the record, this may not work too well, at least that’s what I have observed.
If nothing else helps you here, I suggest uploading your flow and I could take a look to see if I can help.
I hope this helps you with your issue.
There is another regular expression you can use to detect null, empty or only spaces. The sample is below. You’ll get what you need and won’t have to hard-code the name of the var in the property dialog.
BRANCH on '/rec/tailOfAK5' /[^ ]/: MAP (rec/tailOfAK5 is not null, is not empty and has one or more non-space chars) $default: SEQUENCE (rec/tailOfAK5 is empty, null or has only spaces)
If you’re happy with using the copy only if… approach, try using
Note the leading ‘/’ which scopes the record/var.
My bad…I had this value for generateRequiredRags set to true in recordToDocument flow which displays the tag even though I check whether the value is null or not.
Is there any easy way to do casting while mapping from one record ref to another record ref. I do have to cast a double value to an integer value.
Thanks once again for your prompt reply for my last post.
I am doing this using a transformer. and then a built in method. Thanks very much.