boolean isCorrectNumRange(str _rangeValue) { boolean ret = false; if (match("^[0-9. -=<>]+$", _rangeValue)) { ret = true; } return ret; }
container getRangeValue(str _rangeValue) { container tmp; int len, rangeLen = strLen(_rangeValue); InventQty qtyFrom = 0, qtyTo = 0, qtyTmp; boolean fromSet = false, toSet = false; str val; _rangeValue = strLRTrim(_rangeValue); if (1 == strFind(_rangeValue, '>', 1, 1)) { if (2 == strFind(_rangeValue, '=', 2, 1)) { tmp = [subStr(_rangeValue, 3, rangeLen - 1), '']; } else { tmp = [int2str(str2int(subStr(_rangeValue, 2, rangeLen - 1))+1), '']; } } else if (1 == strFind(_rangeValue, '<', 1, 1)) { if (2 == strFind(_rangeValue, '=', 2, 1)) { tmp = ['', subStr(_rangeValue, 3, rangeLen - 1)]; } else { tmp = ['', int2str(str2int(subStr(_rangeValue, 2, rangeLen - 1))-1)]; } } else { tmp = str2con(_rangeValue, '..'); } len = conLen(tmp); val = strLRTrim(conPeek(tmp, 1)); if (val) { fromSet = true; } qtyFrom = str2int(val); if (len > 1) { val = strLRTrim(conPeek(tmp, 2)); if (val) { toSet = true; } qtyTo = str2int(val); } else { qtyTo = qtyFrom; toSet = true; } if (fromSet && toSet && qtyFrom > qtyTo) { qtyTmp = qtyFrom; qtyFrom = qtyTo; qtyTo = qtyTmp; } return [qtyFrom, qtyTo, fromSet, toSet]; }
If you found value in what I share, I've set up a Buy Me a Coffee page as a way to show your support.
Buy Me a CoffeeNo comments. Be the first one to comment on this post.
DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics 365 FO.
Authors are allowed to set their own "buy me a coffee" link.
Join us.