No right or wrong answers, just looking for a cleaner way to do this.
So, I’m still no coder, but I will admit, setting variables in widgets is absurd when you have 24 to do like I am dealing with. So I’m doing this in C#. Yes, let’s hear it. I’m ready.
I started with the green commented-out section at the end (dataset field = input). That worked fine.
Then a lightbulb - if my user passes a blank (empty string) for a value, do I interpret that as
The user wants to overwrite the data to now be blank?
Or they just want to skip over it and leave it as the original value?
And the answer was that he wanted blank to mean “leave it alone.” On the flip side, if he wants to actually clear a field (set it to an empty string), we agreed to send over the string "NULL".
What if you put the current value into all your fields? That way when you re-write their values to update, you don’t have to check if they wanted it to be blank vs. leave it alone.
I’m not sure what your form looks like… but I’m saying display to the user in the fields they can edit what the current value is. Like bind the field to the appropriate view/column on that form. Then the fields would act like any other field where when you load the form, the existing values populate there and if you want to change them you can… or you can leave them as is.
Either that or you could possibly have it loop through each column in the row but I’m not sure what that syntax would be. I’m used to looping through rows, not columns. So instead of writing UpdateValues 9 - 24 times you could write a single foreach statement that would be something like this:
foreach (var eachColumn in dsInspPart.UD13[0].Columns)
{
UpdateValues(eachColumn.Name, eachColumn.Value);
}
But I have no idea if that’s even close to valid properties. Nor if there are more columns than the ones you mentioned that it would then try to update even if you didn’t want them to.
Nope, you can’t make methods in BPM. But you can make actions (no return) or functions (returns something). You have to put them at the top of your code because they must be created before you call them, but once they are made, you can call them like any other method.
Add as many inputs as you need.
Action<string, string> WT = (myVar, myVar2) =>
{
//do stuff here, myVar, myVar2 are your parameters passed in
};
Add as many inputs as you need, then the last one is your output.
Func<string, string> GetFunction = (inString) =>
{
//do stuff here using inString
return myResult;
};
I’m not sure if my syntax is exactly right, but should be close enough for you to get the gist.