Populate Group IDs

PHOTO EMBED

Fri Jan 07 2022 23:17:36 GMT+0000 (Coordinated Universal Time)

Saved by @rebukt #javascript

jQuery(document).ready(function ($) {

  var isLoggedIn = !!$(".logged-in").length;

  var isDealSubmit = !!$(".page-id-548").length;
  var isSingleDeal = !!$(".single-deal").length;
  var groupIdField = "#input_19_39";

  function scenarioDriver() {
    for (var i = 0; i < scenarios.length; i++) {
      if (scenarios[i].condition) {
        scenarios[i].outcome();
      }
    }
  }

  var scenarios = [
    {
      condition: isLoggedIn,
      page: isDealSubmit || isSingleDeal,

      outcome: function () {
        if (abUser.group_id.indexOf("14") > -1) {
          $(groupIdField).val("Consultants");
        } else if (abUser.group_id.indexOf("15") > -1) {
          $(groupIdField).val("Technology Partners");
        }
      },
    },
  ];

  scenarioDriver();


});
content_copyCOPY

Workato is a customer that has many groups created. Members (users) are added to these groups based on the group rules. Group rules can be created at different levels (like user, company, etc.). Workato has a Consultants group (https://workato.allbound.com/allbound-settings/?app=groups&view=group_view&id=14#edit) and a Technology Partners Group (https://workato.allbound.com/allbound-settings/?app=groups&view=group_view&id=15#edit). Members (users) belong to the Consultants Group if both of the following rules are met: (1) Company Partner Classification Includes: SSI, RSI or GSI (2) Company Name = Workato - The group ID for this group is '14', which is noted in this URL: https://workato.allbound.com/allbound-settings/?app=groups&view=group_view&id=14#edit Members (users) belong to the Technology Partners Group if both of the following rules are met: (1) Company Partner Classification Includes: Technology Partner, Community Developer or PE (2) Company Name = Workato - The group ID for this group is '15', which is noted in this URL: https://workato.allbound.com/allbound-settings/?app=groups&view=group_view&id=15#edit --- Request: The integrations team at Allbound would like to populate a hidden field on the deal registration form with a value, depending on if the end user submitting the deal is a Consultant or Technology Partner. The use case could be to enable conditional logic on the form, and display different fields to different partners. Another use case could be that they are mapping this hidden field to the customer's CRM, which could change the integration flow. The snippet above will populate 'Consultants' for users that belong in Group ID 14, and 'Technology Partners' if the user belongs in group 15. To test if the implemented code works as expected, you will need to switch to a user of group 14 before inspecting the page. Under the Elements tab, Ctrl+F to search for 'field_19_39'. You'll expand the arrows twice until you get to 'input 39' and here you can verify what the value is. You should see 'Consultants' if the code was implemented successfully. Switch out of that user and switch to a member of group 15 to repeat the QA process for 'Technology Partners'.