CA Service Management

Expand all | Collapse all

How to copy a value from on column to another on save?

  • 1.  How to copy a value from on column to another on save?

    Posted 04-11-2018 03:16 PM

    Hey,

     

    So I am trying to populate a custom column 'zdivision' in the call_req table, with a value from the customer.location.site.id. The plan is to have the customer's site populate that custom column with its value when a new ticket is saved. Then when the ticket is opened again the two fields will be identical, but the custom field will be an editable dropdown while the customer's site will be a read-only field.

     

    I currently have a way to do this using some javascript but it is causing a Delayed Server Response error sometimes. So I am seeking other ways of doing this, I would think that a <PDM_SET> should work, but I am still kinda new to SDM development and I am unsure if I used it correctly. This is what I have in my set:

    <PDM_SET arg.zdivision = $arg.customer.location.site.id>

     

    If anyone has any tips on using the PDM_SET or any other methods of completing this goal please let me know.

     

    Thanks



  • 2.  Re: How to copy a value from on column to another on save?

    Broadcom Employee
    Posted 04-11-2018 10:57 PM

    Hi DArcey,

    as I understand it, the '$args' object is passed in to the form when the form is generated.  So "$args.customer.location.site.id" in a new ticket will probably be empty, as the customer field is not populated before the form is displayed.  I'd probably use a post_validate trigger to achieve your requirement.  Something like this - untested, may contain fatal syntax or logic errors, use at your own risk and be prepared to debug :-):

    zcr_triggers.mod

    OBJECT cr {   
       TRIGGERS {
         
          POST_VALIDATE zSetCustLocId(customer) 9999
          FILTER(customer { -> NOT_NULL } && EVENT( 'INSERT' ));

       };
    };


    zcrSetCustLocId.spl

    cr::zSetCustLocId(...) // is passed 'customer'
    {
       string method; method = "cr::zSetCustLocId";
       uuid theCust;
       theCust = (uuid)argv[3];
       logf(TRACE,"%s, called for customer %s", method, (string)theCust);
       int theSiteId;
       theSiteId = (int)expand(format("&{U'%s' = cnt.id->location.site.id}", (string)theCust));
       if (!is_empty(theSite_id))
       {
          logf(TRACE,"%s, setting zdivision to %d", method, theSiteId);
          this.zdivision = theSiteId;
       }
    }

    Hope that helps.

    Regards,

    James