Home › Forums › General discussion › Unable to get the setFieldValue function to work.
- This topic has 5 replies, 2 voices, and was last updated 8 years, 2 months ago by Alexander Bautz.
-
AuthorPosts
-
-
October 7, 2016 at 01:22 #13542
Hi Alexander,
I have a button on a form that calls a java script function that is in the Custom JS section. That function uses setFieldValue to set a field. The field is single line text. The code fails to set the value in the field.
Here is the line of code.
setFieldValue(“tmpSubCodes_Process_x0020_Owner_5″,”a”);
I have double checked the internal name and it is correct.
However that same java script function uses the getFieldValue to retrieve a value from a field on the same form and that works just fine.
I am using Dynamic Forms for SharePoint DFFS Backend v4.3.73 with spjs-utility version: 1.266.
I have used the setFieldValue function in another site and it works perfectly.
Could this issue be related to perhaps one of the .js files not being the correct release?
I put IE in debug mode and this is the error that it encountered.
“Unable to set property ‘innerHTML’ of undefined or null reference”
I have resorted to using the following as a workaround:
document.getElementById(sFieldID_ProcessOwnerContactEmail).value = ProcessOwnerContact2;
Any help would be greatly appreciated.
Harley
-
October 8, 2016 at 07:48 #13559
From your code snippet it looks like you have the wrong quotes around your field name. Ensure those are correct by retyping them.
You can list all fields by typing this in the developer console and hitting enter:
spjs.dffs.fields
Alexander
-
October 13, 2016 at 18:41 #13627
Hi Alexander,
I retyped the quotes and added 2 alerts, 1 before and 1 after the setFieldValue and only the first alert runs.
alert(“1 -Almost Finished”);
setFieldValue(“tmpSubCodes_Process_x0020_Owner_5″,”a”);
alert(” 2- Finished”);
return;
Any ideas as to why this fails?
Harley
-
October 14, 2016 at 19:11 #13652
The quotes still looks a bit odd in the code snippet you posted above. If you are 100% sure they are the correct type (do not copy-paste, but retype all four quotes) and have ensured the fieldintenalname is correct (in the “Field table” tab in DFFS), you can try this code:
$("#dffs_tmpSubCodes_Process_x0020_Owner_5 input").val("Your value here");
Alexander
-
October 18, 2016 at 16:02 #13690
I noticed that the double quotes looked funny as well. I retyped that line of code character by character and it would still not work. Also double checked the internal field name and it is correct.
However, I was able to get your sample to work!
Thanks for all of your help.
Harley
-
October 18, 2016 at 20:46 #13694
I’m glad you figured it out.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.