Forum Discussion
Thank you @Spiro_Taleski. That would work, but I also need to run the Data Validator snap on other fields as well.
I have managed to work around the issue for now by using a Conditional snap before the Data Validator that checks for null values in the $DOB field and transforms them to an empty string ‘’. Then use the this regex that matches either an empty string or the date: ^$|\d{1,2}/\d{1,2}/\d{4}$
While the Conditional snap may work in this case, I would also recommend looking at the Mapper snap with the following $.get expression as an alternative for the same:
(Note: Pass through is checked so that the only fields you need to concern with are those you need to run through the validator as a string.)
I don’t know that it’s a huge benefit, but it seems cleaner/easier to me and it allows for additional transformations/mappings on other fields in the same snap.
Helpful tip: In this forum, you can use the icon to encapsulate code to preserve formatting
^$|\d{1,2}/\d{1,2}/\d{4}$
I think you can do this with a Mapper since the “Target Path” is a JSON-Path. Using a path with some wildcards (
*
), you can spread thequiz_id
value across all the questions. Here’s a suggested Mapper configuration:The first row copies the
quiz_id
to all of the categories (e.g. “sports”) and then the questions (e.g. “q1” and “q2”). Since I set the Mapper to pass through the input doc, the second row deletesquiz_id
from the input.Community7038_2020_03_09.slp (3.8 KB)
Thanks a lot @tstack it worked great.
below is the actual case which I wanted to implement using this logic but it doesn’t seem to be working
Scenario to be implemented:
with reference to JSON payload (refer attached pipeline), the item array has field “lineItemId”, this field i need to be mapped inside AccountingCodingBlockAssignment below ProductRecipientPartyInternalID field.
here if for same lineItemId, there are more then one objects under AccountingCodingBlockAssignment, then it should map respective the “lineItemId” below each objects ProductRecipientPartyInternalID field.i have kept one expected json snap in pipeline for better understanding, archiving this would help us to design desired complex mappings.
Hi,
I have developed logic to archive this through JavaScript, can anyone help me to translate it in snaplogic expression language ? (newPayload is created by passing the actual payload)
let itemlen = newPayload.PurchaseOrderERPRequest_V1.PurchaseOrder.item.length;
for (i = 0; i < itemlen; i++) {
let BlockAssignmentlen = newPayload.PurchaseOrderERPRequest_V1.PurchaseOrder.item[i].AccountingCodingBlockDistribution.AccountingCodingBlockAssignment.length
for (j = 0; j < BlockAssignmentlen; j++) {
newPayload.PurchaseOrderERPRequest_V1.PurchaseOrder.item[i].AccountingCodingBlockDistribution.AccountingCodingBlockAssignment[j][“lineItemId”] = newPayload.PurchaseOrderERPRequest_V1.PurchaseOrder.item[i].lineItemId
}
};In a nutshell want to know the functions/snaps which can be used in snaplogic to archive this.
Thanks
Related Content
- 4 years ago
- 11 months ago