Extract Form Fields with Business Rule

alicepyclik
Tera Contributor

I am attempting to create a Business Rule that sends form field data from an HR form to Qualtrics. I am following this documentation from Qualtrics but am having trouble formatting the Business Rule code. Below are the problems I am experiencing:

  • The Business Rule should run only when a form field equals a certain value. In "Filter Conditions," I have been able to filter to the correct form but I am not sure how to filter to a specific form field.
  • The Business Rule should extract data from 3 fields within the form. Again, I have been able to filter to the form but not to a field, so I do not know the field names to include in the code.

How can I filter to the fields, rather than just the form itself? I appreciate any help the community can provide.

5 REPLIES 5

BalaG
Kilo Sage

Hi @alicepyclik   can you include some screenshots that show what filter conditions you were able to specify?

 

--

Bala

Thanks! Below is the filter I added. The name of the HR Form is "Request for Termination." I'm not sure what I would add under this to filter to a specific field within the Request for Termination form.

 

BR Filters.png

Hi @alicepyclik  don't think dot walking is allowed on this filter, probably due to performance reasons. You can do the filtering inside your BR script under the 'Advanced' tab

 

hope this helps

--

Bala

That makes sense. I decided to complete the filtering in Qualtrics since I'm more familiar with that platform.

 

The BR uses the code below, but the JSON passed to Qualtrics is empty. I would expect the variables in the code to have passed through. Do you know what could have gone wrong? The bolded part is what I added, the non-bold part comes directly from a REST message I configured. (Should I create a separate community post for this?)

 

(function executeRule(current, previous /*null when async*/) {
    try {
        var r = new sn_ws.RESTMessageV2('Trigger Exit Survey', 'Post method');

        var body = {};

        var target = new GlideRecord('sn_hr_core_case_workforce_admin');
        target.addQuery('sys_id', '=', current.sys_id);
        target.query();
        if (target.next()) {
            body["u_method_of_delivery"] = target.u_method_of_delivery.getDisplayValue();
            body["u_exit_survey"] = target.u_exit_survey.getDisplayValue();
            body["u_email_address"] = target.u_email_address.getDisplayValue();
            body["subject_person"] = target.subject_person.getDisplayValue();
            body["u_employee_id"] = target.u_employee_id.getDisplayValue();
        }
       
        r.setRequestBody(JSON.stringify(body));

        var response = r.execute();
        var responseBody = response.getBody();
        var httpStatus = response.getStatusCode();
    }
    catch(ex) {
        var message = ex.message;
    }
})(current, previous);