Populating a Dynamic List in Configurator Using Code

Is it possible to populate a dynamic list using code from a UD method or from the condition editor within the dynamic list editor? (or anywhere else)

For example I wrote a method that can return possible options for a combo box based on different inputs within the configurator and data pulled from a lookup table. Right now it is formatted as a string with a comma separated list of values. I was planning on writing code that would parse these to create a dynamic list. Am I able to do that or something similar and if so how?

I can’t just create different predefined lists for each condition as it is much too complicated for that, so code seems like the best way to accomplish this.

As a followup, is displaying a single string the extent of creating a dynamic list where the data source is a UD Method? I can’t find a way to do anything else with that setting since any method that returns a type other than string(even a string array), gets excluded from the source list.

3 Likes

alternatively is there a way to pull values from a configurator live into a BAQ to generate a dynamic list? I just started messing around with using Erp.PcLookupTblValues in a BAQ but I also need access to the configurator inputs. (for example: Inputs.RailSizeCombo.Value)

edit: Am I able to get them from here? Any help would be awesome, otherwise if I figure this all out I’ll update this post with how to do it.

1 Like

Brian, did you ever figure this out. We’re currently in the same boat. I have a case with Epicor Support about it, I’ll reply to this if I get a resolution. But if you or anyone else has a resolution, it’d be much appreciated.

I was able to alter code from the “Understanding User Defined Methods” video from Epicor University to do this. An example is below. It returns only CustID’s that contain “5”:

return string.Join(“~”, (from custRow in Db.Customer where custRow.CustID.Contains(“5”) == true select custRow.CustID).ToArray());

This type of code works with other database tables. I was able to change the table to PcConData (and change the field names) and get similar code to work. The code without the where clause would return all CustIDs in the database. The where clause limits it to CustIDs containing “5”. Contains function is sweet, used link below for documentation on it:

I’m still waiting to hear back from Support whether you’re supposed to be able to do this thru BAQ. I’ll update this thread when I hear back. If BAQs are supposed to work and support can help me figure out how, I’ll also ask them which method is better for system performance and respond to this thread. But the above is definitely a working solution.

Hi Tyler,

I read your post with interest as it addresses the issue I am trying to get done. In my configurator, I want to filter out a combobox that lists parts, based on attributes selected using other configurator inputs (2cbo’s, 2 txt’s). Using code, I can easily build the where clause from that, but do not know how to build programmatically the equivalent to your (from….CustID) statement highlighted below. I need to build the where clause using code as I do not know which inputs the user has used to narrow down the selection. Would you be able to point me in the right direction? slight_smile: [quote=“tyler, post:4, topic:37022”]
return string.Join("~", (from custRow in Db.Customer where custRow.CustID.Contains(“5”) == true select custRow.CustID).ToArray());
[/quote]

Here is an example of the code that we use. Basically, we store all of our potential list items in PcConData. Lines 2-5 of the code below find the values associated with that combo box. The 6th line further limits the list based on the value of another input - chrSizeCode.

Hope this helps. Let me know if you’re still stuck. I don’t think I fully understand your problem, specifically “I need to build the where clause using code as I do not know which inputs the user has used to narrow down the selection.”

return string.Join("~", (from PcConData in Db.PcConData where
PcConData.Company == “TS” &&
PcConData.PartNum == “CFGTB” &&
PcConData.TypeCode == “Option” &&
PcConData.Key1 == “cmbRecept” &&
PcConData.ShortChar01.Contains(Inputs.chrSizeCode.Value) == true /Limit the list based on another input value/
select PcConData.Description).ToArray()); /Return each value the code found to an array, which shows up as a list of values that the user can select in the combo box/

I’m not sure if you gentlemen are still looking for answers but I’ve worked with a guru of configurators and he’s taught me to use the configurator lookup tables. With that you can do a whole bunch of things including filtering the results based on other inputs.

Here you can see where the lookup tables are as well as an example of one of mine.

This is an example of the configurator filtered based on inputs.
image

The UD Method code that I am using is below.
/Change these to the 5 Column names that are in your table./
string LT_QuestionCol = “QUESTION”; /this Col is the group of options… equal to the passed ComboName from above/
string LT_AnswerCol = “ANSWER”; /* this Col contains the actual resulting option ID*/
string LT_DescCol = “DESCRIPTION”; /* this Col contains the description of the Answer*/
string LT_SortByCol = “SORT”; /* we sort by this Col./
string LT_Filter1Col = “FILTER1”; /
we will further filter by this column./
string LT_StartDate = “StartDate”; /
we will further filter by this column./
string LT_EndDate = “EndDate”; /
we will further filter by this column.*/

return string.Join("~",(from Ques in Db.PcLookupTblValues
		join Desc in Db.PcLookupTblValues          	on new {Ques.Company, Ques.RowNum, Ques.LookupTblID} equals new {Desc.Company, Desc.RowNum, Desc.LookupTblID }
		join Answ in Db.PcLookupTblValues		on new {Ques.Company, Ques.RowNum, Ques.LookupTblID} equals new {Answ.Company, Answ.RowNum, Answ.LookupTblID}
		join Seq in Db.PcLookupTblValues		on new {Ques.Company, Ques.RowNum, Ques.LookupTblID} equals new {Seq.Company, Seq.RowNum, Seq.LookupTblID}
		join Filt1 in Db.PcLookupTblValues		on new {Ques.Company, Ques.RowNum, Ques.LookupTblID} equals new {Filt1.Company, Filt1.RowNum, Filt1.LookupTblID}
		join SDate in Db.PcLookupTblValues		on new {Ques.Company, Ques.RowNum, Ques.LookupTblID} equals new {SDate.Company, SDate.RowNum, SDate.LookupTblID}
		join EDate in Db.PcLookupTblValues		on new {Ques.Company, Ques.RowNum, Ques.LookupTblID} equals new {EDate.Company, EDate.RowNum, EDate.LookupTblID}
		where Ques.LookupTblID == LookupTblID
		&& Ques.ColName == LT_QuestionCol
		&& Ques.DataValue== Question
		&& Answ.ColName == LT_AnswerCol
		&& Desc.ColName == LT_DescCol
		&& Seq.ColName == LT_SortByCol
		&& Filt1.ColName == LT_Filter1Col
		&& (Filter1 == "" || (Filt1.DataValue.Contains(Filter1)))
		&& SDate.ColName == LT_StartDate
		&& (SDate.DataValueDate <= DateTime.Today || SDate.DataValue == "")
		&& EDate.ColName == LT_EndDate
		&& (EDate.DataValueDate >= DateTime.Today || EDate.DataValue == "")
		orderby Seq.DataValue
		select new {Answer = Answ.DataValue,Description = Desc.DataValue}).ToList()
			.Select(r => string.Join("`",r.Answer,r.Description))) + "";
1 Like

Thank you so much for getting back to me Tyler. Being new to C# and Epicor, I ended up using two different dynamic queries, the choice of which is determined by a checkbox. I see that much greater potential in what you suggest, and that’s why I contacted you. But I am just a bit shy at this point and needed to get a prototype going to show the users.
I very much appreciate that you took the time to think about it and get back to me. Thank you.

Waoh, this is awesome Maxwell. Your post is going to be such a great resource for me! I was just saying to Tyler that I was new to C# and Epicor (not to programming or SQL though), and so I won’t implement this approach right away - I want to firm up my basis first. But I can see how this will open doors wide for me.
Thank you for sharing this pearl!