Expand my Community achievements bar.

SOLVED

How show different ENUM lists based on variable in input form?

Avatar

Level 2

How can I decide what enum list to show in a delivery based on a variable I have in the input form?

I don't need anything for creating/changing the enum values or the enum lists themselves. ONLY the path itself that leads to a existing Platform Enumeration list. So the path itself should be the only thing that could be different based on the variable.

Right now I am able to show the enum list (from Enumerations under Platform) and be able to chose between the enums with this:

(I have changed names to make it easier to understand)

In delivery schema:

 

<attribute dbEnum="xtk:enum:one_keyword"
           label="Keyword" length="100" name="keyword"
           type="string"/>

 


In delivery Input form:

 

<container colspan="1">
      <input label="Keyword" xpath="@one_keyword"/>
</container>

 


The enum list is in Platform-->Enumerations and not made in the schema, since I am dependent on not having to change the schema to add/change enum values. (So I am not currently using <enumeration></enumeration> )


But I want to be able to, based on a variable (e.g that's stored in /tmp/ in the input form) or similar, to change the path to the enum list that will be displayed.

So, if the variable I have has the value "one", I want this to be the chosen displayed enum list path:
"xtk:enum:one_keyword"

If the variable's value is "two"
"xtk:enum:two_keyword"

If the variable's value is "three"
"xtk:enum:three_keyword"

 

... and so on.

Kind of like this if that was possible, or something similar:
"xtk:enum:"+enumVar+"_keyword"

Or if I could define the dbEnum directly in the input form instead of in the schema, that would also be nice! Is this possible?

I will have maybe 20 different enum lists, so would be great if there's a way without making 20 attibute copies.

Would really appreciate replies and suggestions!

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hi,

 

Do you need to do this in input form?

 

If you ultimate aim is to add Platform enumerations based on different variables, you can achieve this via Javascript also.

Design a JS: which will insert values in xtk:enum based on variable passed.

There are two approach possible:

1) Pass list of variable in workflow and perform insert operation in xtk:enum using JS activity.

2) Use SOAP call to your JS function which will perform insert on each variable value.

 

Thanks.

View solution in original post

7 Replies

Avatar

Level 10

Hi @HeleneHH ,

you can use sysFilter.

<sysFilter>
<condition expr="variable_location = value1"/>
</sysFilter>

 Theoretically, it could be done with enabledIf bu you must adjust it properly to your use case.

<enumeration basetype="string" default="A" name="something">
<value enabledIf="variable_location = value1" label="A" name="A" value="A"/>
<value enabledIf="variable_location = value1" label="B" name="B" value="B"/>
<value enabledIf="variable_location = value1" label="C" name="C" value="C"/>
</enumeration>

Regards,

Milan

Avatar

Level 2
Thank you so much for your reply! I am not defining the enumerations inside the schema itself though, they only exists in Platform-->Enumerations, so that when adding a new enum in that list, it will automatically show up in the list in the input form, without needing any changes to schema. I will have several different enum lists (in Platform-->Enumerations), and the enum list showing should be based on the user / a variable value. Can I still use sysFilter and enableIf for this?

Avatar

Level 10

Hi @HeleneHH,

yes, based on user you may set something like this.

<sysFilter>
<condition expr="[enumValueOperatorRel/@operator-id] = $(@operator-id)"/>
</sysFilter>

Regards,

MIlan

Avatar

Level 2

@Milan_Vucetic 
Thank you so much again for looking into this! But I am not sure if this is what I am after though.

It's not really about who can access what. And that still seems like I will have to define more than just the path to the dbEnum in schema if I was to use this?

I am bound to only use sysEnum/System Enum with ONLY A PATH to an enum list being in Platform-->Enumerations (and the path itself may vary without needing to define all possible paths). So I should not need to add neither any enum list or any enum values directly in schema. Nothing other than a way to change the path itself based on other values.

I don't need anything for creating/changing the enum values or the enum lists themselves. ONLY the path itself that leads to a existing Platform Enumeration list. So the path itself should be the only thing that could be different based on the variable.

So let's say if the variable is "dave", the path to the enum list should be "xtk:enum:dave_keyword". And I will NOT need to define anything for "dave" any other place than making sure "dave_keyword" Enumeration list exists in Platform--> Enumerations. So when the variable suddenly is "anna" or anything else, the path would now be "xtk:enum:anna_keyword" (without me having to add "anna" to schema). Not sure if I manage to explain what I need properly, sorry if this is confusing!

Avatar

Correct answer by
Level 9

Hi,

 

Do you need to do this in input form?

 

If you ultimate aim is to add Platform enumerations based on different variables, you can achieve this via Javascript also.

Design a JS: which will insert values in xtk:enum based on variable passed.

There are two approach possible:

1) Pass list of variable in workflow and perform insert operation in xtk:enum using JS activity.

2) Use SOAP call to your JS function which will perform insert on each variable value.

 

Thanks.

Avatar

Level 2

Hi @Jyoti_Yadav ! Thank you for your reply!

I do not need to do it in the input form, but it would be the easiest

I will look into what you suggested! But it seems to me that this is for inserting values into the enum list(s)?

I don't need anything for creating/changing the enum values or the enum lists themselves. ONLY the path itself that leads to a existing Platform Enumeration list. So the path itself should be the only thing that could be different based on the variable. If this makes sense to you?

Avatar

Level 9

Hi,

You can achieve that using below options:

1) Query on xtk:enumValue table and give condition as:

Jyoti_Y_0-1591332078069.png

 

Here variable you can either pass by placing JS before query as: vars.enumValue='XYZ'

or you can pass this variable when calling an external sugnal.

 

2) You can create a JS which will perform operation of get and will give you array of values associated with that enum.

 

Thanks.