Forum Discussion
4 Replies
- j_angelevskiContributor III
Hi @fajosa,
Yes, you can remove that field, we will need to iterate over the
Projectfield since it is an array, try with the following expression:jsonPath($, "Project[*]").map(val => val.ApporvalType.toLowerCase() == "greater than equal to" ? val.filter((v, k) => k != "upperlimit") : val)This will remove the
upperlimitfield if ApprovalType is “Greater than equal to” otherwise it will ignore it.- fajosaNew Contributor II
That worked!! Thank you @j.angelevski
Also, is it possible we can map the upperlimit to the lowerlimit?
so that whenever, ApprovalType ==“Greater than equal to”, $lowerlimit should have the value of $upperlimit which works along with the filter out of upperlimit.
Appreciate your help @j.angelevski 😀
Thanks,
F.- j_angelevskiContributor III
Yes, it is possible to map the upperlimit to the lowerlimit, you can try with the following expression:
jsonPath($, "Project[*]").map(val => val.ApporvalType.toLowerCase() == "greater than equal to" ? val.extend({lowerlimit: val.upperlimit}).filter((v, k) => k != "upperlimit") : val)Here I’m using the
extend()method, with this you can add a specific field to the object or overwrite an existing one with a new value. In this case theupperlimitvalue will be assigned to thelowerlimitfield, resulting in overwrite of that same field.