Configurator/C# Question

We have a configurator that’s creating a part off of a several different inputs with a dash separator character.

My goal is to reduce the part creation to one input, and just have the other inputs feed into this one input.

So for example the inputs could be - CupSize, LabelColor, and ArtworkID

How can I make an input expression so that CupSize.Value, LabelColor.Value, and ArtWorkID.Value feed into the one input?

You’ll have to put a on Validate event on each of the sub-inputs that then as they change /validate you write a bit of C# to set the MasterInput.Value = CupSize.Value + LabelColor.Value + ArWorkId.Value

Okay what will the validate event be like for those sub-inputs? I do have a document rule for the MasterInput but I’m still not 100% sure that’s going to work the way I want

I think there’s an OnLeave or OnChange event you can put on each of those sub-inputs ?

There are the ‘On Field Changed’ and ‘On Field Validating’ actions and it looks like those are expression based… Is that what you mean?

Field Validated runs before it allows change. It’s good but there are also some caveats with it.

Field Changed will fire after the validation (at which point you could still do some validation\changes in code)

I’m assuming I need to add an expression to those sub-inputs to write to that MasterInput, but I’m not sure how. I’ve tried Inputs.CupSize.Value = Inputs.‘MasterInput’.Value; but that doesn’t do anything when I test it…

My document rule on the ‘MasterInput’ is:

Inputs.PartNumber.Value = (Inputs.CupSize.Value)+ '-' +(Inputs.LabelType.Value)+ '-' + (Inputs.CupColor.Value)+ '-' + (Inputs.LidColor.Value) + '-' + (Inputs.Straw.Value) + '-' +(Inputs.ArtWorkID.Value);

Which I’m hoping it ends up doing something like this for the PartNum - “32-NAT-BLK-BLK-000-123456” but I can’t really test it yet since the sub-inputs aren’t doing anything

Anyone got any ideas?

Just write the code on the event to write the MasterInput.Value (the same code you wrote for the Master Input should work there

Inputs.PartNumber.Value = (Inputs.CupSize.Value)+ ‘-’ +(Inputs.LabelType.Value)+ ‘-’ + (Inputs.CupColor.Value)+ ‘-’ + (Inputs.LidColor.Value) + ‘-’ + (Inputs.Straw.Value) + ‘-’ +(Inputs.ArtWorkID.Value);

Is this on the On Field Validating action for the sub inputs? If so, I cannot use that expression (gives a few errors).

I tried it on the Masterinput and it did nothing. I was assuming (with the rule configured) that I could select the CupSize from the dropdown (say for example 12oz) and it would update the MasterInput field with a “12-”. Then I would select the labeltype in the next dropdown and that would update the MasterInput from “12-” to “12-IML-” but right now the MasterInput field just stays blank throughout the entire process.

What are the errors?

Well yesterday I was getting errors saying that I couldn’t have the Inputs.MasterInput.Value in the left side of the expression - but I just copied and pasted it and now it says the Syntax is correct…

But when I went to test it Epicor crashed. I’m going to have to mess around with the expressions a bit for each subinput I think… I’ll update you in a bit

Edit/Update: I made the CupSize On Field Validate Expression the following and it still crashes -
Inputs.PartNumber.Value = Inputs.CupSize.Value + '-';

Got it to work finally. No idea why it was crashing, but I re-saved and now whenever I test it, it actually writes the info to the PartNumber field. Thank you Jose

1 Like

Wondering if it could have been a cache issue.