The CreatorCon Call for Content is officially open! Get started here.

Scripting record producer submissions with catalog api

johnny27
Tera Contributor

I'd like to add records to the HR Case table in a business rule using a record producer set to an hr_case table.

      var cart = new Cart();

      var catItemGR = new GlideRecord("sc_cat_item");

      catItemGR.addQuery("name", "Contractor Update");

      catItemGR.query();

      if (catItemGR.next()) {

              var item = cart.addItem(catItemGR.sys_id);

              cart.setVariable(item, 'opened_by', lv_user_obj.sys_id);

              cart.setVariable(item, 'Select_the_contractor_you_wish_to_upd', lv_user_obj.sys_id);

              cart.setVariable(item, 'email', lv_current.variables.reqfor_email);

              cart.setVariable(item, 'change_end', lv_current.variables.change_end);

              cart.setVariable(item, 'contractor_name', lv_user_obj.name);

              cart.setVariable(item, 'contractor_email', lv_user_obj.email);

              cart.setVariable(item, 'contractor_department', lv_user_obj.department);

              cart.setVariable(item, 'contractor_supervisor', lv_user_obj.manager);

              cart.setVariable(item, 'contractor_location', lv_user_obj.location);

              var rc = cart.placeOrder();

              gs.log(rc.number + " should be an HRC number","AMP");

      }

Even though the Contractor Update is a record producer for the hr_case table, the above code   submits a sc_request record instead.

Does anyone know if placeOrder needs to be specified so that the record is submitted to the correct table?

15 REPLIES 15

and you can script that?   Is it easier that what you pointed to above?