CA Service Management

Expand all | Collapse all

custom look-up field issue on Activity Log page

  • 1.  custom look-up field issue on Activity Log page

    Posted 03-23-2015 02:11 PM

    Our requirement for Level1 Analyst role is to enter a Work Type on New Labor activity form as well as to be able to edit the Work Type on the existing Labor activity form.

     

    To satisfy the above requirement, I created a new Activity Type "Labor" as similar to "Log Comment". Then created a customized menu item "Labor" under ticket "Activities" menu and clicking on "Labor" item brings up the same New Activity Form (detail_alg.htmpl form) along with a customized look-up field "Work Type". The "Work Type" field (zWork_Type) in alg is SREL to custom table zWork_Type.


    I have added few conditions in detail_alg.htmpl form for Level1 Analyst role to be able to save or edit the new Work Type field on Labor activity form. It works as expected on New Activity form but when the analyst tries to edit the Labor form for modifying the existing Work Type field, the following error "Invalid attribute name: 'zWork_Type' provided for Work Type lookup" is seen on the top of the form and also the 'search as you type' functionality in Work Type look-up field is broken. If anyone had a similar requirement or has achieved this on Activity form then please advise on how to get this working.



  • 2.  Re: custom look-up field issue on Activity Log page

    Posted 03-24-2015 06:59 AM

    The detail_alg.htmpl form is a bit tricky. It is used in two different situations, and I assume, that your problem is related to this fact.

     

    When creating a new activity, two objects are accessible/controled at the same time.

      1. The related ticket attributes can be accessed by using $args.<attribute name>
      2. The alg attributes are accessible by using $args.alg.<attribute name>

    I assume, that your lookup field reflects this by using something like

     

        <pdm_macro name=dtlLookup hdr="Work Type" attr=alg.zWork_Type>

     

    When updating an existing alg, you only have the alg object under control, and its attributes are accessible by directly using $args.<attribute name>.

    That means, you need to differentiate between these two situations, for example by using something like

     

    <pdm_if $args.ACTIVITY_LOG_TYPE != "">

        <pdm_macro name=dtlLokkup hdr="Work Type" attr=alg.zWork_Type>

    <pdm_else>

        <pdm_macro name=dtlLokkup hdr="Work Type" attr=zWork_Type>

    </pdm_if>

     

    Give it a try and let me know if this works

    Regards

    ............Michael



  • 3.  Re: custom look-up field issue on Activity Log page

    Posted 03-24-2015 12:15 PM

    I agree with you, as I tried few modifications to my code in detail_alg.htmpl file but to no luck yet. See below for my existing code that throws out the error on the activity form when tried to edit and update the work type field but works fine on New Labor Activity form to add a Work Type.

     

    Part 1 -

    <PDM_MACRO name=dtlTextbox hdr="Time Spent" attr=time_spent evt="onBlur='validate_duration_ts(this)'" maxlength=100>

     

    Added the below code under the "Time Spent" line.

     

    <PDM_IF "$args.type" == "LBR">

    <PDM_IF "$prop.form_name_3" == "edit" && "$env.NX_ACTIVITY_LOG_SECURITY" == "WRITE_NEW">

    <PDM_MACRO name=dtlStartRow>

    <PDM_MACRO name=dtlLookupReadonly hdr="Work Type" attr=zWork_Type link=yes>

    <PDM_ELSE>

    <PDM_MACRO name=dtlStartRow>

    <PDM_MACRO name=dtlLookup hdr="Work Type" attr=zWork_Type autofill="no" factory="zWork_Type" link=yes make_required=yes>

    </PDM_IF>

    </PDM_IF>

     

    Part 2 -

    <PDM_MACRO name=dtlTextbox hdr="Time Spent" attr=alg.time_spent evt="onBlur='validate_duration_ts(this)'" maxlength=100>

     

    Added the below code under the "Time Spent" line.

     

    <PDM_MACRO name=dtlStartRow>

    <PDM_IF "$args.alg.type.code" == "LBR">

    <PDM_MACRO name=dtlDropdown hdr="Work Type" attr="alg.zWork_Type" factory="zWork_Type" make_required="yes">

    </PDM_IF>



  • 4.  Re: custom look-up field issue on Activity Log page

    Posted 03-24-2015 12:42 PM

    Can you please post the output of

        bop_sinfo -d alg

    and

        bop_sinfo -fd zWork_Type

     

    Regards

    ............Michael



  • 5.  Re: custom look-up field issue on Activity Log page

    Posted 03-24-2015 12:48 PM

    E:\PROGRA~1\CA\SERVIC~1>bop_sinfo -daq zWork_Type

    Factory zWork_Type < zWork_Type >

    Attributes:

       id                   INTEGER UNIQUE

       producer_id          LOCAL STRING(20)

       persistent_id        LOCAL STRING(60)

       delete_flag          SREL -> zWork_Type.id ON_NEW {0}

       description          STRING(1000)

       name                 STRING(100)

       sym                  STRING(100)

       last_mod_dt          DATE ON_CI {NOW}

       last_mod_by          SREL -> cnt.id ON_NEW {USER} ON_CI {USER}

     

    E:\PROGRA~1\CA\SERVIC~1>bop_sinfo -daq alg | find "zWork_Type"

       zWork_Type           SREL -> zWork_Type.id



  • 6.  Re: custom look-up field issue on Activity Log page

    Posted 03-24-2015 05:47 PM

    I did not see any mistake in your stuff, so I started to do the same on my box. And guess what, I got the same problem. I played around a lot and wasn't realy able to understand, what's going on. Sometimes the field in the New Activity Log was working, and the field in the "Update" page did not, and the next time it was vice versa.

    Nevertheless, I got a solution which is working right know, in both cases.

    I did not use a dtlDropdown in the one case, but dtlLookup in both cases.

    And I added the parameters common_name_attr=sym and factory=zWork_Type. So they look like

    ...

    <PDM_MACRO name=dtlLookup hdr="Work Type" attr=zWork_Type common_name_attr=sym factory=zWork_Type>

    ...

    and

    ...

    <PDM_MACRO name=dtlLookup hdr="Work Type" attr=alg.zWork_Type common_name_attr=sym factory=zWork_Type>

    ...

     

     

    Does this work for you too?

    Regards

    .............Michael



  • 7.  Re: custom look-up field issue on Activity Log page

    Posted 03-26-2015 06:02 PM

    I tried this on my Sandbox environment and the custom look-up field works as expected on both New and Edit activity forms. I really appreciate your help on this one.



  • 8.  Re: custom look-up field issue on Activity Log page

    Posted 03-28-2015 04:43 PM

    New code is failing only on one scenario as the New Activity form is still saved with blank value in work type field though it is a required field on the form level. The scenario is, an analyst enters a value in Work Type look-up field which brings up all the matching values if any and the form is saved without selecting any value then it just puts up empty value in Work Type field which is not desired and that directly impacts our reporting with empty Work Type value. Any suggestions on tweaking your code to fix this one pending issue ?



  • 9.  Re: custom look-up field issue on Activity Log page

    Posted 04-09-2015 04:20 AM

    Sorry for the late response. The only idea I have for this point is creating a spell trigger which conditionaly checks the Work Type field depending on the activity type.

    Kind regards

    ..............Michael