I'm trying to do some runtime calculations and lookups which is causing me some problems on mobile form.
I have a form which displays employee name (read only) upon item creation. The form needs to automatically lookup the name from another list to get kilometers travelled in the current year. so the lookup needs to be based on 2 conditions where the Employee Name = formEmployeeName and the Year = current year.
Then I have 2 needs for the returned Kilometers value.
1. the KM needs to be displayed on desktop and mobile (which I'm finding that lookups are not supported for Mobile), so I can get away with not displaying it on mobile, but if there is a way. That would be great.
2ndly which I cannot skip is I need the value to be able to pass it to a form variable in runtime. So based on the range of the kilometers, I need to pass a certain mileage factor and do runtime calculations.
I first tried to use a lookup, where the user have to select their Employee ID from a list and then display the KM. which is very non-user friendly, can show other users ID's and also doesn't work on Nintex mobile and is causing the form to break. Totally wrong solution.
I found this article https://community.nintex.com/community/tech-blog/blog/2016/02/10/nintex-form-runtime-function-as-parameter-to-javascript… which explains how to use Javascript to pass a value from a calculated field, then display on a single line of text on the form.
I haven't written Javascript before and this seems more complicated than what I'm trying to do, and was wondering if someone can give me a quick hand...
Here is what I did:
- I created a list column (single line of text) called "KMTravelled"
- I have a form variable called mileage-factor that should take the KMTravelled and checks the value and returns a certain decimal number. Currently it's getting the information manually.
- I created a calculated field that has the runtime lookup function as below. (Note that this function only looks up based on name but I still need it to check the year as well because this might bring in a previous year's cumulative KM)
|
- I changed the Employee Name field settings (which is in display only mode and defaulted to created by user). to have a Javascript
- I also adjusted the settings of the KMTravelled field to be as above with Client Javascript variable name =
- Then it comes to creating the Javascript function according to the article, and I have no idea how to do that!! Not even sure if that's will solve my problem or should I try a different approach.
Help please!! I need this fixed this week... It seems possible and should have been done before.. Just need the quick "how-to".
Thanks in advance!