This topic contains 3 replies, has 0 voices, and was last updated by k_dunc 6 years, 9 months ago.

  • Author
    Posts
  • #21488 Score: 0

    k_dunc
    • Contributions: 0
    • Level 1

    Hi all,

    I have a Field Change function operating on an Expense Report form. This function checks to see if the user has changed the value of a number of Expense column fields, and performs some processing / validation depending on the column field changed. One such process is to set the Tax Code based on the user selecting a Currency (when 'Use Multi Currency' is ticked).

    I am finding that the function is correctly triggered when the Currency is changed, and also correctly sets the Tax Code field, however, based on the Execution Log, I can see that it runs the passage of code for the Currency Field Change twice. That is, it appears that when the user changes the Currency, my 'if name == currency' condition triggers, then based on certain rules, I set the Tax Code field, which then triggers the Field Change function again (which it should as a field has indeed just been changed – the Tax Code). This Field Change performs no actions in my script. So after the Tax Code has been set and the Field Change function triggered and run, it then runs the Field Change function again (for a 3rd time) suggesting that the Currency has been changed, which runs my code yet again and sets the Tax Code (for the 2nd time), before running the Field Change function again for the Tax Code field change event (also for the 2nd time), before finally stopping.

    The tab key is only pressed only the once after changing the Currency in order to navigate to the next column, so I'm at a loss to explain why the function is called 4 times when only 2 fields have been changed.

    Can anyone explain what is happening here, and perhaps suggest a better way to set a Transaction Column Field based on a change to a different Column Field?

    Thanks heaps,

    Kirk.
    This is a cached copy. Click here to see the original post.

  • #21489 Score: 0

    Olivier Gagnon NC
    • Contributions: 0
    • Level 1

    Did you try setting the FireFieldChange paramter to false on your setFieldValue call to see if that would resolve the issue?

  • #21490 Score: 0

    ksmith.ks
    • Contributions: 0
    • Level 1

    Changing Currency also triggers Exchange Rate to change, so it's possible your function could work as a Post Source instead, however it should work perfectly fine as a field change function.

    You can add alert('name=' + name); to the beginning of the function call and that will display which fields are triggering the field changed function, with another alert to let you know when you've entered the condition of name == 'currency' and you can debug that way.

    You said that a number of the fields are scripted for field changes, is it possible that changing Tax Code or Exchange Rate triggers another field change in the script that is then changing Currency?

    Hope this helps!

  • #21491 Score: 0

    k_dunc
    • Contributions: 0
    • Level 1

    Thanks Olivier Gagnon NC and ksmith.ks for your input. I do have various execution log statements, thus I can see when and how often this function gets called. I have an execution log call as the very first line, giving me the name of the field each time the function is called, then within each 'if' I also write various things back to the log file.

    Olivier, thanks for your suggestion. I did try that, but regrettably, that did nothing. Upon doing further research, this Currency column field clearly is a controlling field linked to other dependent fields. Refer to this answer.

    I will attempt the Post Source and see if that helps.

    Thanks again.

You must be logged in to reply to this topic.