CA Service Management

Expand all | Collapse all

CI and affected end user

  • 1.  CI and affected end user

    Posted Aug 31, 2016 12:23 PM

    Hi Team,

     

    I'm stuck with few problems here: 

     

    Scenario 1:

    I'm working on the employee page and I want the affected end user field to populate the user name of the person who is logging the call. This page already has Reported by field which fetches value from $cst.combo_name, this displays the name of the person. To achieve my requirement I created a hidden attribute as customer_combo_name, then in the loadAction() I mentioned document.main.forms["Set.customer"]=$cst.combo_name.

     

    Problem: 

    After the page is loaded, I can see the username in the Affected end user field. However, post clicking on Save button it displays an error saying required attribute missing, though the value is visible. What I observed is, since it is lookup, if manually select the value or press tab in that field and click save button, the ticket is created successfully.

    Is there any way to set default value to the affected end user field apart from above method?

     

    Scenario 2:

    I have CI dropdown field in the above employee page which displays the CI attached to the current logged in user. This dropdown should display the list of CIs attached to the Affected End user. If we change the affected end user then the CIs should also change and display accordingly. 

     

    If this is not possible then, can I have the same attribute with two different controls, like one would be dropdown and other would be the lookup

     

     

     

    Thanks

     



  • 2.  Re: CI and affected end user

    Posted Aug 31, 2016 02:49 PM

    Hi Johny,

     

    Scenario 1 : Data Partition

    You can create a data partition and link it to the role being used by your employee.

    Add a "Default value" constraint to it looking something like : customer = @root.id

     

    Scenario 2 : EXTRA_URL for lookup and whereclause for dropdown

     

    For a lookup :

    extraURL="ADDITIONAL_WHERE=resource_contact = U\'$cst.id\'

     

    For a dropdown :

    whereclause="resource_contact U\'$cst.id\'"

     

    You can customize the detail_xx.htmpl page of your choice(IN or CR).

     

    Hope this helps.

     

    Pier



  • 3.  Re: CI and affected end user

    Posted Aug 31, 2016 05:47 PM

    I think he's looking for the CIs attached to the users Environment tab.  If that's the case the where clause would be something like.

     

    "cntref.cnt IN U\'$cst.id\'"



  • 4.  Re: CI and affected end user

    Posted Sep 01, 2016 05:01 AM

    The above code is working fine but I want it bring the CIs of the affected end user dynamically. If the affected end user is changed then the CI dropdown should populate accordingly.



  • 5.  Re: CI and affected end user

    Posted Sep 01, 2016 04:44 AM

    Hi Johnny,

     

    For scenario1, you can try to coding like;

     

    document.main_form.elements["SET.customer"].value = "$cst.id";
    document.main_form.elements["customer_combo_name"].value = "$cst.combo_name";

     

    Regards,

    Turker



  • 6.  Re: CI and affected end user

    Posted Sep 01, 2016 05:24 AM

    I have tried that but when i'm using below code it is not working as required

     

    else if (document.main_form.elements["SET.affected_resource"].value == "")

    {
    alert('$cst.combo_name');   //this displays the name of the user properly
    alert(document.main_form.elements["KEY.customer"].value); //this gives a blank value!!! any idea why???

    if('$cst.combo_name' == document.main_form.elements["KEY.customer"].value)
    {
    if(document.main_form.elements["SET.affected_resource"].length > 1)
    {
    alert("Please select value for CI");
    return false;
    }
    else
    document.main_form.elements["SET.affected_resource"].value == " "
    }
    }



  • 7.  Re: CI and affected end user

    Posted Sep 01, 2016 05:29 AM

    ok the above issue is resolve using below code:

     

    if('$cst.combo_name' == document.main_form.elements["customer_combo_name"].value)



  • 8.  Re: CI and affected end user

    Broadcom Employee
    Posted Sep 01, 2016 06:09 AM

    Hi Pushpith,

    May you confirm if you have solutions now for both Scenario #1 and Scenario #2?

    Regards,

    Karen



  • 9.  Re: CI and affected end user

    Posted Sep 01, 2016 07:23 AM

    It's possible but complex for htmpl format. Default, web engine  convert htmpl files to html at run time. so by its own object(elements) you can't want to bring the CIs of affected end user dynamically. 

     

    You can applly following steps for this;

     

    firstly you can define jquery.js in your htmpl file <script src="$CAisd/sitemods/scripts/jquery.js"></script>

     

    1. create a new htmpl form and code typing on notebook++ or same text editör, not WSP (file name is form_getci.htmpl)

     

    <!doctype html>
    <PDM_PRAGMA RELEASE=110>
    <html lang="us">
    <head>
    <meta charset="utf-8">
    <title>jQuery UI Example Page</title>
    <script src="$CAisd/sitemods/scripts/jquery.js"></script>
    </head>
    <script>
    var data = new Array();
    </script>
    <body>
    <script>
    data = [
    <PDM_LIST PREFIX=list FACTORY=nr WHERE="resource_contact.id=U'$args.KEEP.customer'">
    {"ci_id":"$list.id", "ci_name":"$list.name", "persistent_id":"$list.persistent_id"},
    </PDM_LIST>
    {"ci_id":"$list.id", "ci_name":"$list.name", "persistent_id":"$list.persistent_id"}
    ];

    parent.cidata = data;
    parent.addCIDataRows();
    </script>
    </body>
    </html>
    <PDM_WSP>

     

    2. Define iframe tag <iframe id="CI_Frame"> in your htmpl file but its display set is hidden.

    3. Define a global array variable in your htmpl file

     

    var cidata = new Array();

     

    4. Define javascript function getCIByCustomer() which will call onchange event of customer  field on your htmpl file

    function getCIByCustomer(obj)
    {
    var queryStr = "$CAisd/pdmweb.exe?SID=$args.SID+FID=$args.FID+OP=DISPLAY_FORM+HTMPL=form_getnr.htmpl+KEEP.customer="+obj.value;
    $$('#CI_Frame').attr('src', queryStr);
    }

    useage;

    <PDM_MACRO name=dtlLookup hdr="Affected End User" attr="customer" evt="onChange=\\\"getCIByCustomer(this)\\\"">

     

     

    5. Define a new function as addCIDataRows() for insert to customer's CIs to Affected Resource field affected resource field type definition must be "dtlDropdown"

     

    function addCIDataRows()
    {
    $$('select[pdmqa="affected_resource"]').html('');
    var html = '';
    for (i=0;i<cidata.lenght-1;i++)
    {
    html += '<option value="'+cidata[i].ci_id+'">'+cidata[i].name+'</option>';
    }
    $$('select[pdmqa="affected_resource"]').html(html);
    }

     

    this codes is dynamicly get CI by customer field definition at run time

     

    Best Regard,

    Turker



  • 10.  Re: CI and affected end user

    Posted Sep 02, 2016 02:26 AM

    Thanks.. I'll check and get back



  • 11.  Re: CI and affected end user

     
    Posted Sep 06, 2016 03:56 PM

    Hi Johnny_2302 - Did birolturker.kara's response help answer your question? If so please mark as Correct Answer. Thanks! 



  • 12.  Re: CI and affected end user

    Posted Sep 07, 2016 02:02 AM

    I have few queries regarding the solution as below:

    1. Firstly you can define jquery.js in your htmpl file <script src="$CAisd/sitemods/scripts/jquery.js"></script>

    Where will I get this javascript file from or are we supposed to create a new script?

    2. I have created and made required changes, however, the same is not working. could this be because of the above file?



  • 13.  Re: CI and affected end user

    Posted Sep 07, 2016 04:24 AM

    Yok can get the latest version of jquery.js file from http://jquery.com, download file and Put it in "sitemods/scripts/" folder

     

    Regards

     

    Türker