Question

FSM6 Form Field Custom Code

  • 14 October 2021
  • 8 replies
  • 141 views

Userlevel 3
Badge +9

How do i get a script to fire on FSM6 form fields and the field has been updated?

 

I have tried ‘AfterValueChanged’ and ‘TextChanged’ but neither fire the script when the value is updated. ‘LostFocus’ fires, but i dont want to use that as it fires when the lookup appears.

 

Thanks in advance


8 replies

Userlevel 5
Badge +12

Hi @MartinF ,

The AfterValueChanged event will be called for Web Client and TextChanged event will be triggered for the smart client. Try to create a new client script like shown in the image.

 

Client Script - Smart Client only

Assign it to the field you wish, in this scenario will be using the description in the Request Screen.
 

Attach to the field - UI Designer.


Then refresh  cache and navigate to the screen in smart client . (I have added an AfterValueChanged event as well for web client)

 

Output - Smart Client
Output Web Client - alert(“Hello”) - Web Client Only

Hope this answer helps

Best Regards,
​​​​​​​Atheeq

Userlevel 3
Badge +9

Hi @Atheeq Maharoof ,

 

This is exactly what i have tried, but the Script does not execute on the Smart Client even with ‘TextChanged’ added (i have both ‘TextChanged’ and ‘AfterValueChanged’ set up on the field in the UI designer)

 

Even a simole client script with just an alert as you described will not fire

Regards,

Martin

Userlevel 5
Badge +12

Hi @MartinF ,

Does the AfterValueChanged event  gets fired in the web client ?

Can you assign it to the description field of request screen and check whether it works ?

After performing the refresh cache , make sure to open the edited screen again (in my scenario its request screen) and check whether it works. 

Make sure the screen is saved and it has been assigned to the role of the user you are using the environment. 

Best Regards,
Atheeq
 

Userlevel 3
Badge +9

Okay, so i tried that and that works although not what i am looking for (i need an ‘AfterUpdate’ not having it fire everytime the user presses a key)

 

I am trying to use the script on the project screen on a custom date time field.  We have two fields (a start and an end) i am trying to add validation to compare the two to ensure that the end time is not before the start time.  The ‘TextChanged’ trigger does not seem to fire on these fields at all. The Lost focus does and almost does what i need, but the fires when the date time lookup is clicked which is not what i want.  I need it to fire after the new value has been entered and after it has been entered, not as it is being entered.

Userlevel 5
Badge +12

Hi @MartinF ,

There isn't any event in the smart client to get fired after the update.  Following is the list of events in the smart client.

 

Events - Smart Client

In order to achieve your requirement you can use the following options.
1. Create a validation business rule for the specific table where the execution type is before insert or update.
2. Write a validation custom client script and assign to the click event of the save button. 

Hope this answer helps

Best Regards,
Atheeq

Userlevel 2
Badge +3

Hi there,

client scripts are primarily for client side validation and other client side logic.

 

client scripts are not intended to handle this use case. You would need a business rule to handle after updates or any database transaction.

 

Adding a client side script after save would have to be carefully thought out because a save will perform an insert, update or will return an error.

 

Hope this helps.

Userlevel 3
Badge +9

Hi @schuster,

 

This is client side validation. We are trying to validate entered data on the smart client before it is saved.  When a client script is attached to the save button, does it perform the save first? or the script first?

 

Martin

Userlevel 2
Badge +3

Hi martin,

 

Client first, then based on the return it will either perform the save if you return true or not save the request if you return false.

Reply