Calling JS function from a Rule

Forums Dynamic Forms for SharePoint Calling JS function from a Rule

Viewing 8 reply threads
  • Author
    Posts
    • #26098
      David M
      Participant

      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…

    • #26116
      Alexander Bautz
      Keymaster

      I think this is because you have a typo in the code.
      Change this:

      return=true;

      like this

      return true;

      Alexander

    • #26126
      David M
      Participant

      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.e

      var 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…

    • #26128
      David M
      Participant

      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.

    • #26136
      Alexander Bautz
      Keymaster

      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

    • #26226
      Leo
      Participant

      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

    • #26243
      Alexander Bautz
      Keymaster

      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

    • #26255
      Leo
      Participant

      Thank you, they were not in the content type. Once I added them, everything started working…

    • #26259
      Alexander Bautz
      Keymaster

      Thanks for the feedback – I’m glad you got it sorted out.

      Alexander

Viewing 8 reply threads
  • You must be logged in to reply to this topic.