DanK2
Apprentice

Use an expression on change event

Hi, I'm still relatively new to K2 and I'm stuck on a problem. I want to run a text expression to update a value once a control has been changed.

 

The user selects a member of staff from a people picker, this will then return the full account name, i.e. domainusername.

 

I need to be able to replace the domain so that I am only left with username. I can use the expression value of a hidden textbox control, this works when the page loads however when my people picker change event fires, the textbox value should be set with said expression but it doesn't work and the textbox is blank.If I remove the expression, the textbox value is domainusername.

 

There must be a way of achieving this? I need to do it at the form level rather than in a workflow, etc. Can somebody please advise? Thanks

0 Kudos
4 Replies
AhmadAbdullah
Apprentice

Re: Use an expression on change event

Dear,

 

Please clarify to better help, "If I remove the expression, the textbox value is domainusername."

do u remove the expression ? then how does the textbox get the domainusername value? 

and from what i know, all you need is to add expression for the textbox and the value of the expression should be the people picker, this will make sure that any value inside the people picker will be display also in the textbox , even when you change the value of people picker, the value of the textbox will be changed to the new one.

if u set the expression as i explained above, it should never return blank, and if it returns blank there might be a problem in your expression, maybe your expression is wrong and returning blank.

double check the expression and maybe try a test one like Concatenate("people picker" , "test")

this should return any value from peoplepicker concatenated with "test" string, if it works perfectly then try using your own expression replacing the domain with empty string.

if anything goes wrong, please post a picture of your expression.

 

Regards.

Kran
Apprentice

Re: Use an expression on change event

HI DanK2,

 

To  replace user FQN  with user name, use replace expression in  "When picker is Resolving" rule. This rule will be already availabe there to resolve ur picker value.

 

To set expression for picker action

  • Add Action "set the properties of control"   here control should be ur  Text box control
  • Under configuration add  the expression and keep  Text field empty

Every time when picker value is resolved , replaced value will appear in textbox.

 

 

 

 

DanK2
Apprentice

Re: Use an expression on change event

Thank you both, I will post back on here with my results when I have time. Hopefully next few weeks. Thanks again!

0 Kudos
DanK2
Apprentice

Re: Use an expression on change event

I've got this working. This is how I did it...

 

I have an additional control (hidden textbox) which has an expression against it. The expression has the value of the people picker with a Replace statement using the "Empty String" in the replace statement.

 

I have an On Change event on the people picker, I use a Transfer data action and set the value of the textbox to the Expression that I created. This seems to work perfectly.

0 Kudos