Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
emotyp101
Partner - Contributor II
Partner - Contributor II

Trigger on field canceling

Hello,

I have a selection trigger on a field EXAMPLE_FIELD which sets the field value to a specific value depending on the current login.

E.g.: User A logs in and get EXAMPLE_FIELD = 1

User B logs in and get EXAMPLE_FIELD = 2

This ensures that the current user can't leave the selection on EXAMPLE_FIELD because everytime they try to change it it changes back to the configured one.

I'm doing this with multiple if statements as shown below:

SET exampleFieldValue =

        if(OSUser()='db\526','1',                 // User A

        if(OSUser()='db\534','2',                 // User B

        '*'));

The code sets the selection of EXAMPLE_FIELD depending on the current user. If User C logs in, they get the selection * so everything is selected.

My Problem: Now I want every other user than A and B to freely chose the selection. The code above sets the selection always back to ALL SELECT because of the *.

Is there a possibility to not change the current selection on the last else statement?

So if User C selects 3 in EXAMPLE_FIELD it will remain on 3?

Hope someone knows how to solve this problem.

Thanks

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Are you trying to stop user A and B from selecting other values and allow any selection for C? If so, try like:

if(OSUser()='db\526','1',                 // User A

        if(OSUser()='db\534','2',                 // User B

'('&GetfieldSelections(EXAMPLE_FIELD, '|')&')'

));

View solution in original post

7 Replies
shun_wong
Partner - Contributor III
Partner - Contributor III

Have you tried removing the '*' and leaving it as ''?

tresesco
MVP
MVP

Try just removing the else part '*', like:

if(OSUser()='db\526','1',                 // User A

        if(OSUser()='db\534','2'                 // User B

));

emotyp101
Partner - Contributor II
Partner - Contributor II
Author

This is not working too. It counts as an empty selection then.

So if you select '1' in EXAMPLE_FIELD the selection gets cleared instantly.

tresesco
MVP
MVP

Are you trying to stop user A and B from selecting other values and allow any selection for C? If so, try like:

if(OSUser()='db\526','1',                 // User A

        if(OSUser()='db\534','2',                 // User B

'('&GetfieldSelections(EXAMPLE_FIELD, '|')&')'

));

emotyp101
Partner - Contributor II
Partner - Contributor II
Author

Yes this does not work too.

The selection gets cleared after selection a value

emotyp101
Partner - Contributor II
Partner - Contributor II
Author

// EDIT //

I now tried to put in   getfieldselections(EXAMPLE_FIELD)   as last else statement.

This works if just one value is selected in the listbox. If I select multiple values it jumps back to a cleared selection.

Any idea on how to get this working with multiple selections in the listbox?

emotyp101
Partner - Contributor II
Partner - Contributor II
Author

This works!

Thank you so much !