PatL
(PatL)
May 26, 2025, 3:59am
1
Hi Team,
In App Studio is the json editor able to subsitute in all occurrences?
My example is i’ve added a erp-function and i’m trying to send my function a custom dataset.
The erp-function is just sending “{RcvHead.PackSlip}” instead of the value and I’m not sure if it should work or not.
I’ve had a good look for other posts a lot of questions about the return DS but none about the arguments.
1 Like
Hey Pat!
I have also struggled with this exact thing.
If I remember correctly, I wasn’t able to substitute within the json editor. Instead, I ended up having to pass either the entire dataview as it is, or pass individual values and then build the ds myself within the function.
If you only have to pass the partNum for your function, why not have this passed as a string param and build the rest of the columns within the function?
Here’s an example from part of a function that I use to update all levels of a price list at once for a given part:
try{
ds = new Erp.Tablesets.PriceLstTableset();
try{
var existingDataSet = PriceLstPartsService.GetByID(priceListOrder[i], PartNum, UOMCode);
if (existingDataSet.PriceLstParts.Any()){
foreach (var row in existingDataSet.PriceLstParts){
existingPrice = row.BasePrice;
if (existingPrice == priceListGroups[priceListOrder[i]]){
slideoutMsg += "Skipping group, value is equal to previous.\n";
slideoutMsg += "\n";
skipTurn = true;
break;
}
var newRow = ds.PriceLstParts.NewRow();
newRow["Company"] = row["Company"];
newRow["ListCode"] = row["ListCode"];
newRow["PartNum"] = PartNum; // override
newRow["BasePrice"] = priceListGroups[priceListOrder[i]]; // override
newRow["DiscountPercent1"] = row["DiscountPercent1"];
newRow["DiscountPercent2"] = row["DiscountPercent2"];
newRow["DiscountPercent3"] = row["DiscountPercent3"];
newRow["DiscountPercent4"] = row["DiscountPercent4"];
newRow["DiscountPercent5"] = row["DiscountPercent5"];
newRow["QtyBreak1"] = row["QtyBreak1"];
newRow["QtyBreak2"] = row["QtyBreak2"];
newRow["QtyBreak3"] = row["QtyBreak3"];
newRow["QtyBreak4"] = row["QtyBreak4"];
newRow["QtyBreak5"] = row["QtyBreak5"];
newRow["UnitPrice1"] = row["UnitPrice1"];
newRow["UnitPrice2"] = row["UnitPrice2"];
newRow["UnitPrice3"] = row["UnitPrice3"];
newRow["UnitPrice4"] = row["UnitPrice4"];
newRow["UnitPrice5"] = row["UnitPrice5"];
newRow["CommentText"] = row["CommentText"];
newRow["UOMCode"] = UOMCode; // override
newRow["GlobalPriceLstParts"] = row["GlobalPriceLstParts"];
newRow["GlobalLock"] = row["GlobalLock"];
newRow["CurrencyCode"] = row["CurrencyCode"];
newRow["CurrencyCodeCurrSymbol"] = row["CurrencyCodeCurrSymbol"];
newRow["DMTSysRowID"] = row["DMTSysRowID"];
newRow["ListCodeListDescription"] = row["ListCodeListDescription"];
newRow["PartDescription"] = row["PartDescription"];
newRow["PartNumIUM"] = row["PartNumIUM"];
newRow["PartNumPartDescription"] = row["PartNumPartDescription"];
newRow["PartNumPricePerCode"] = row["PartNumPricePerCode"];
newRow["PartNumSalesUM"] = row["PartNumSalesUM"];
newRow["PartNumSellingFactor"] = row["PartNumSellingFactor"];
newRow["PartNumTrackDimension"] = row["PartNumTrackDimension"];
newRow["PartNumTrackLots"] = row["PartNumTrackLots"];
newRow["PartNumTrackSerialNum"] = row["PartNumTrackSerialNum"];
newRow["PartPricePerCode"] = row["PartPricePerCode"];
newRow["PartSalesUM"] = row["PartSalesUM"];
newRow["PartSellingFactor"] = row["PartSellingFactor"];
newRow["RowMod"] = "U"; //Set rowmod to UPDATE
newRow["SellingFactorDirection"] = row["SellingFactorDirection"];
newRow["SysRevID"] = row["SysRevID"];
newRow["SysRowID"] = row["SysRowID"];
ds.PriceLstParts.Add(newRow);
}if (skipTurn){
continue;
}
PriceLstService.Update(ref ds);
slideoutMsg += "Updated. Original Price: " + Math.Round(existingPrice, 5) + " Changed To: " + priceListGroups[priceListOrder[i]] + "\n";
}else{
slideoutMsg += "Issue retrieving current values for this part. Please contact Connor with error for PriceLstPartsService.GetByID.\n";
}
}catch (Exception ex){
if (ex.Message.Contains("Record not found")){
PriceLstService.GetNewPriceLstParts(ref ds, priceListOrder[i], PartNum);
if (ds.PriceLstParts.Any()){
foreach (var part in ds.PriceLstParts){
part.BasePrice = priceListGroups[priceListOrder[i]];
part.PartNum = PartNum;
part.UOMCode = UOMCode;
part.RowMod = "A";
}
PriceLstService.Update(ref ds);
slideoutMsg += "Added to price list. No existing price found. Uploaded with price: " + priceListGroups[priceListOrder[i]] + "\n";
}else{
slideoutMsg += "Issue retrieving default values for PriceLstParts. Please contact Connor.\n";
}
}else{
slideoutMsg += "Please contact Connor with the following error.\n";
slideoutMsg += "Error: " + ex + "\n";
}
}
}
Found another example - UD02 table
Ice.Tablesets.UD02Tableset() instead of a dataset, but similar!
result = "OK";
this.CallService<Ice.Contracts.UD02SvcContract>(svc =>
{
try
{
var missingFields = new List<string>();
// Check for missing or empty fields
if (string.IsNullOrEmpty(key1)) missingFields.Add("Unique ID");
if (string.IsNullOrEmpty(character01)) missingFields.Add("Part");
if (string.IsNullOrEmpty(shortchar01)) missingFields.Add("Warehouse");
if (string.IsNullOrEmpty(shortchar03)) missingFields.Add("Adjustment Bin");
if (number02 == null) missingFields.Add("Adjustment Quantity");
if (string.IsNullOrEmpty(shortchar05)) missingFields.Add("Reason Code");
// Build error message if any missing fields
if (missingFields.Any())
{
string missingFieldsMessage = "Error: The following fields are missing or empty:<br><b>";
foreach (var field in missingFields)
{
missingFieldsMessage += $"{field}<br>";
}
missingFieldsMessage += "</b>";
result = missingFieldsMessage;
return;
}
string whseResult = "";
try
{
// Current company ID
var companyID = Session.CompanyID.ToString();
// Query to get Warehouse description
var descriptionList = from warehse in Db.Warehse
where warehse.Company == companyID
&& warehse.WarehouseCode == shortchar01
select warehse.Description;
// If a description is found, return it; otherwise, return an error message
if (descriptionList.Any())
{
whseResult = descriptionList.FirstOrDefault();
}
}
catch (Exception ex)
{
whseResult = "";
}
// Init keys
string key2 = "", key3 = "", key4 = "", key5 = "";
var ts = new Ice.Tablesets.UD02Tableset();
Ice.Tablesets.UD02Row row;
bool isNew = false;
try
{
// Try to get existing
ts = svc.GetByID(key1, key2, key3, key4, key5);
row = ts.UD02[0];
row.RowMod = "U";
}
catch
{
// Record not found: create new
svc.GetaNewUD02(ref ts);
row = ts.UD02[0];
row.Key1 = key1;
row.RowMod = "A";
isNew = true;
}
// Assign values (shared logic)
row.Character01 = character01;
row.Date01 = date01;
if (!string.IsNullOrWhiteSpace(date02) && date02.ToLower() != "null")
{
row.Date02 = DateTime.Parse(date02);
}
else
{
row.Date02 = null;
}
row.ShortChar01 = shortchar01;
row.Number01 = number01;
row.ShortChar02 = shortchar02;
row.ShortChar03 = shortchar03;
row.ShortChar04 = shortchar04;
row.Number02 = number02;
row.ShortChar05 = shortchar05;
row.ShortChar06 = shortchar06;
row.ShortChar07 = shortchar07;
row.CheckBox01 = checkbox01;
row.CheckBox02 = checkbox02;
row.Company = Session.CompanyID;
row.ShortChar08 = shortchar08;
row.Character02 = character02.Replace("'", "").Replace("\"", "");
row.ShortChar09 = whseResult;
row.ShortChar10 = enteredPerson;
row.ShortChar11 = decisionPerson;
row.ShortChar12 = totalPrice;
// Save changes
svc.Update(ref ts);
result = "OK";
}
catch (Exception ex)
{
result = "Error: " + ex.Message;
}
});
Input param example (the columns I want to update with a value from the calling application)
PatL
(PatL)
May 26, 2025, 11:55pm
4
Thanks @Connor_St_Louis !
I half suspected it might not work - yeah pasing the entire DS might be an option.
I might try and use the temporary DS i’ve seen floating around and chuck values in that.
Oh how I wish I could just chuck a couple of lines of js in this ui.
1 Like
Good luck on your journey