Home › Forums › Classic DFFS › Calling JS function from a Rule
Tagged: Rules Javascript
- This topic has 8 replies, 3 voices, and was last updated 5 years, 5 months ago by Alexander Bautz.
-
AuthorPosts
-
-
July 17, 2019 at 16:38 #26098
Hello,
I have setup a rule that I want to trigger manually from a JS function. In the Rules menu I have the “If this trigger” field set to “Custom JavaScriptFunction” then “This value” is set to the name of the function I created in the custom JS tab. I have tried using both functionName & functionName() in the ‘This value’ field but keep getting a pop-up saying “functionName is undefined” when it runs.Thank you…
Attachments:
-
July 18, 2019 at 12:06 #26116
I think this is because you have a typo in the code.
Change this:return=true;
like this
return true;
Alexander
-
July 18, 2019 at 16:11 #26126
Thanks Alexander, apologies for the basic oversight.
I am also having difficulty getting getFieldValue() & setFieldValue() to return a field’s value in my list.
I’ve tried many variations of the example in the user guide i.evar myRichTextValue = getFieldValue('MultiLineRich');
with no luck. the IE web debugger says “Unable to get property ‘value’ of undefined or null reference.
Is there something I need to do to fully qualify my list element (i.e. Listname->itemID->Column name because it seems as though just specifying the field name as in the examples is not working for me.
Finally, FWIW, I have also been experimenting with document.getElementById(id); also with no luck.
many Thanks…
-
July 18, 2019 at 17:40 #26128
I should also mention that the field is on my list but not the form, so I have been calling the function with dispform == false (
getFieldValue('MultiLineRich',false);
I have also ensured that I am using the internal name of the field.
-
July 19, 2019 at 09:00 #26136
I’m not sure what you mean by “not in the form” – is it not in the content type so it is not available to add in any tab in DFFS? – if so, you cannot access the value with this function (because it only interacts with the fields that are actually available in the form), but will have to do a query to find the list item and pull the value from the DB.
Also, the FieldInternalName MultiLineRich must be replaced with your actual FieldInternalName (unless it is the actual name) – see the Fields tab in DFFS config for a list of all field names.
Alexander
-
July 23, 2019 at 14:47 #26226
Hi Alex,
The Field’s internal names that I am trying to retrieve using get/setFieldValue are ‘ApprovalName’ & ‘ApprovalDate’. They both exist in the Fields tab on DFFS. Their Field Types are ‘SPFieldUser’ & ‘SPFieldDateTime’ respectively. The intent is that these fields get updated with the user name and timestamp when the user clicks an approve button. These two fields are therefore not visible when the user clicks on the edit icon from within the list, I have attached a screenshot from the Tabs config in DFFS if it helps.The issue is that neither getFieldValue nor setFieldValue seem to work correctly for these fields. I have tried getFieldValue on standard text fields and it works great but I cannot seem to have either get or setFieldValue work for these Date & name fields.
In List Settings, ApprovalName is type ‘Person or Group’ and ApprovalDate is type ‘Date and Time’.
I am calling the functions as follows:
`getFieldValue(‘ApprovalName’);
getFieldValue(‘ApprovalDate’);
setFieldValue(‘ApprovalName’,’Name that I want to set’);
setFieldValue(‘ApprovalDate’,[’07/23/2019′]);`Finally, I have attached a pic with what I see when I view source on the Dffs form.
Thank you
Attachments:
-
July 24, 2019 at 10:19 #26243
Do you see the field in the tab in the DFFS form? – I guess you want to hide these fields in the final form, but to troubleshoot you need to have them visible.
If you don’t see the fields in the form even if you have added them to the tab it might be that you have content types enabled in the form and these fields are not added to the content type.
Alexander
-
July 24, 2019 at 21:09 #26255
Thank you, they were not in the content type. Once I added them, everything started working…
-
July 25, 2019 at 09:46 #26259
Thanks for the feedback – I’m glad you got it sorted out.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.