enum = variable check

0
Hi, I'm trying to process some imported data, and in one section we have to create an association to an object based on an enumeration. My imported data has a field lets say status = 'in progress', and now I want to associate with an object e.g. Orders) that contains an enum attribute status = 'in progress'. I retrieve only one object "orders", and then the aim is to link that order to my new object. In the retrieve xPath, I know I can just call [status = 'in progress'], but this process is for dezens if not hundreds of imported rows, and I need to use a variable (the attribute from import. How can I do the following: [status = $iteratorImportObj/status] LR.
asked
3 answers
0

Hi Luis,

You have to retrieve the whole list of objects of that you want to set the status to "InProgress". Then create a loop and iterate through this list. In the loop you make a decision like this: $iteratorList/status = enum.InProgress. If this is true then: You can associate it with the Orders object. If it is false then: Use the continue action (this will make the loop continue going through the list).

It would be faster if you only retrieve the ones that have status InProgress in the first place. This can be done using [status = 'InProgress] on your retrieve action. Follow the same steps as described above but without the decision.

answered
0

Create a variable which will hold the enum. To convert the string to an enum key do something like the following:

if getCaption(MxModelReflection.Status.Invalid) = $Claim/status
then
MxModelReflection.Status.Invalid
else
MxModelReflection.Status.Valid

Then you will have the status in an enum and you can compare this to the retrieve.

answered
0

Hi Luis,

Just to make sure I understand: you have imported data with a string attribute, lets call it status. You have existing objects within Mendix, that have an enumeration attribute called status also. You want to attach your imported data to existing objects based on the value of status (string on imported data and enumeration on existing Mendix objects). If this is the case, you could do the following:

  • Retrieve a list of imported data you want to process
  • Create an enumeration variable with the enumeration in your existing object attribute
  • Create a loop to process each of the imported records one at a time
  • Inside a loop, set the value of an enumeration variable based on the string value of the attribute on imported data
  • Do a retrieve of existing objects using your enumeration variable in the XPath
  • Set the value of the association based on results returned

Could be I am missing something about your requirements, but I think that will do what you need. Depending on the numbers of imported objects and objects to attach to inside of Mendix, this microflow may take a considerable time to execute. In this case, you can create a Processed boolean on the imported data entity, and retrieve groups of objects (say 100 or 100), that have not been processed yet. In this way, you can break up the work into bite sized pieces.

Hope that helps,

Mike

answered