Scheduled script to update field on cmn_location table daily. Need help with script

galavodasal
Giga Expert

I can do this with a client script but I don't think that would work since we need the data updated on the forms daily for an export.

I figure I have to first query the cmn_location table and then add the setValue command but I'm not sure of syntax and how to query through all records.

query (cmn_location)

var DM = g_form.getReference('u_district_manager');

g_form.setValue('u_dm_email', DM.email);

current.update

Also, where can I schedule scripts? I swear there was a module in Fuji for scheduled scripts that would appear after elevating security privileges, but I do not see it in Helsinki.

Thanks!

1 ACCEPTED SOLUTION

galavodasal
Giga Expert

Got it, here's the scheduled script:



find_real_file.png


View solution in original post

6 REPLIES 6

Deepak Kumar5
Kilo Sage

System Definition --> Scheduled job


Write a scheduled script. you have to write server side script here.


HugoFirst
Kilo Sage

I'm not clear what you're trying to accomplish.


Are you trying to set a field named u_dm_email_in the cmn_location entry to the value of the email address for the person listed in the u_district_manager field?


If so, then you might be better served with an insert/update business rule on the cmn_location table.   It could fill in the u_dm_email field for you anytime the record changes.       You would avoid the daily update, which would be redundant for the most part. ( unless the district manager changes daily ).


Yep you got it. We have a District form (cmn_location) with a District Manager field (u_district_manager) and a District Manager Email field (u_dm_email). We need to run a scheduled script to update the District Manager Email field (u_dm_email) based off of the District Manager field (u_district_manager).



We dump this data to an export set daily which is then imported elsewhere. Currently, the District Manager Email field is empty and we need to run a script that will pull the email address from the District Manager field (u_district_manager) and dump it in District Manager Email (u_dm_email).



I tried the business rule idea based off an existing business rule we have to update the Location of an RITM based off of a custom Requested For field, but for some reason it's not working on the District table. Although, even if this was working, wouldn't I run into a problem when the District Manager (u_district_manager) is changed? This script would only enter the email address if the District Manager Email (u_dm_email) field was empty. That's why I was thinking a scheduled script would work in this situation.



Here's what I have:



find_real_file.png


When you update your cmn_location record,     are any errors logged?



EDIT:


Also, line 3 of your script should not have the word ".variables." in it.


I'm assuming that this is a custom field you have added to the cmn_location table.


If so, then that line would read:



if ( current.u_dm_email != '' )