CA Service Management

  • 1.  Custom Column in CR not Getting Updated

    Posted Jan 18, 2018 05:20 AM

    Hi Team,

     

    I had a requirement in CA Service Desk in which we had a custom column in pcat object zescalationcode and a same custom column of same data type i.e. string in cr as well. We had a requirement that when an employee save the incident, the zescalationcode field in call_req table gets updated with the value associated with the same column from pcat object depending on the category selected by the employee. For this, in detail_in of employee form, I had created a javascript function as follows:

     

    function myFunction()
    {
    var var_category=document.main_form.elements["KEY.category"].value;
    //alert("Variable is: " + var_category);
    <PDM_LIST PREFIX=ci WHERE="delete_flag = 0" FACTORY=pcat>
    if (var_category == "$ci.sym")
    {
    //alert("Value Matched");
    document.main_form.elements["SET.zescalationcode"].value="$ci.zescalationcode"
    }
    </PDM_LIST>
    }

     

    I called this function as follows:

    <PDM_MACRO name=dtlHier hdr="Incident Area" attr="category" autofill=yes common_name="ss_sym" factory=pcat_in_ss make_required=yes size=30 evt="onChange=myFunction()">

     

    Somehow, it is not updating the zescalationcode field in the cr object. Apart from it, this function is only getting called when we are providing the category value after typing the characters and selecting from auto-fill options. We need that this function gets called even if the employee select the category from the lookup option. When we try to call this function on onBlur event, it is getting called repeatedly and we need to close the browser window to get rid of that.

     

    Kindly provide your suggestion on this or an alternative approach that can make this task easier.

     

    Thanks & Regards,

    Balram



  • 2.  Re: Custom Column in CR not Getting Updated

    Posted Jan 18, 2018 08:45 AM

    Hi Balram,

    $ (dollar sign) attributes being generated by pre-processor so you can't affect them using JavaScript.

    And here is an anwser why events like onchange, onblur doesn't trigger: https://communities.ca.com/thread/241790530-how-can-i-make-a-textbox-readonly-based-on-the-customers-area-selected-from-… 

     

    So, depending on data size you can preload all possible values and check them on-the-go or use server callback to check every changed value separately.

     

    Regards,

    cdtj



  • 3.  Re: Custom Column in CR not Getting Updated

    Posted Jan 18, 2018 10:20 AM

    Hi cdtj,

     

    Thanks for your response.

     

    Is it possible that when the employee click on submit to save the incident, the value of custom column zescalationcode in pcat object (associated with selected value of category) gets updated in the zescalationcode column of the newly created incident?

     

    To be on little simpler side, it will also work if we can set a fixed value of zescalationcode in call_req table (let's say 1) for fixed values of pcat values in call_req table. Kind of trigger that fire immediately as soon as new record inserted in call_req table and set zescalationcode depending on pcat id values.

     

    Can you provide a spel code that can achieve this? 

     

    Regards,

    Balram



  • 4.  Re: Custom Column in CR not Getting Updated
    Best Answer

    Posted Jan 18, 2018 11:40 AM

    if you don't want to implement custom callback logic, you can use this workaround:

    - out-of-the-box category change causes properties update, even if category haven't any properties defined;

    - you can add your custom code into property managing form (can't say exactly but one of them: dyn_properties.htmpl, load_properties.htmpl);

    on ticket form add hidden input with id:

    document.writeln('<input type="HIDDEN" id="zescalationcode" name="SET.zescalationcode" value="">');

    define something like this on that props form:

    var zelem = ahdframe.document.getElementById("zescalationcode"); // fetch your hidden input
    // if zelem is undefined, try get as: ahdtop.ahdframe.document.getElementById("zescalationcode")
    var zecode = "${args.category.zescalationcode}"; // fetch attr from category
    alert("Applying " + zecode + " to " + zelem.name); // remove me after testing
    zelem.value(zecode);

     

    Regards,

    cdtj



  • 5.  Re: Custom Column in CR not Getting Updated

    Posted Jan 19, 2018 02:01 PM

    Hi cdtj,

     

    Thanks. It was very helpful.

     

    There is another thing that I need your help. We have custom columns zlocation and zsite in the CR object. We want that as soon as the Employee save the incident (Employee detail_in.htmpl), the location and site of the employee gets updated in these custom columns respectively. Can you please provide a spel code that can help us achieving this?

     

    Regards,

    Balram