CA Service Management

Expand all | Collapse all

Create custom button on SDM

  • 1.  Create custom button on SDM

    Posted Feb 16, 2016 09:00 AM

    Hi Community. I need to put a custom button on SDM on detail_cr.htmpl to link to custom object created and related to this CR ticket. how i can do this?



  • 2.  Re: Create custom button on SDM

    Posted Feb 16, 2016 09:34 AM

    This depends on what you mean by "related to this CR ticket". If you have a SREL attribute on the CR then you don't need a button.

     

    Regardless of that this is how you create a button:

    ImgBtnCreate("name_of_button", "Text on the button", "javascriptFunctionToLaunch()", [additional arguments]);

    You can check the examples from the existing buttons on detail_cr.htmpl or if you feel adventurous, go ahead and read the ImgBtnCreate function definition from imgbutton.js The text contains more magic than what initially meets the eye but you'll find out if you decide to dive into the source code.



  • 3.  Re: Create custom button on SDM

    Posted Feb 16, 2016 09:38 AM

    Jussi thanks for the answer. I have a custom object zdemand. This obj have srel with cr object. The relationship are done with spel when i create a new request, but i need to fill all the fields of this object on another window, because if i try to edit the values on the same form detail_cr.htmpl is not possible.



  • 4.  Re: Create custom button on SDM

    Posted Feb 16, 2016 09:47 AM

    Ok. Well, there you have the function on how you create the button and the source file for more details. You can open the detail_zdemand.htmpl with those. You might have to construct a URL for opening the details but it shouldn't be an issue.



  • 5.  Re: Create custom button on SDM

    Posted Feb 16, 2016 09:50 AM

    That's just i need Jussi. I dont know how to construct this URL. For example, for one case, the field "zdemand.id" has the obj relationed with this cr ticket. So this parameter is that i need to pass on the URL, but i don't know how to do this.



  • 6.  Re: Create custom button on SDM

    Posted Feb 16, 2016 09:53 AM

    Ok, I'll need more details on this. Please past the output of the following commands:

    bop_sinfo -da cr | find "zdemand"

    bop_sinfo -dafq zdemand

     

    Do I understand correctly that you want to first create a ticket, then save it and then fill the details of the zdeman object? Or first create the zdemand so that you can refer to it from the cr when you first save it?



  • 7.  Re: Create custom button on SDM

    Posted Feb 16, 2016 10:04 AM

    When i create an cr object with a special category, there are a spel code that creates zdemand obj and stores inside the ID value of the cr, and in the cr obj stores on a field called "zdemand" the id of zdemand obj. On the detail form (detail_cr.htmpl) if i put a field of zdemand obj, the data is displayed, but if i edit and save, the changes are lost. I understand that when i edit a cr ticket only the cr data is saved. So i need to draw a button with this URL wich contains the related zdemand row and open on another window for the fillup of these fields.

     

    All this i must to done of this way because the customer have a looooooots custom fields, and is to many to put all this "zfields" on the cr object. So i decided to create a new object that i can use to extend the cr ticket.

     

    You request:

     

    bop_sinfo -da cr | find "zdemand"

    zdemand              SREL -> zdemand.id

     

     

    bop_sinfo -dafq zdemand

    Factory zdemand < zdemand >

       Rel Attr        = id

       Common Name     = string1

       Func Group      =

       Display Name    = zdemand

       Display Group   =

       REST Operations = CREATE READ UPDATE

       Schema Name     = zdemand

       Producers       = zdemand

     

     

    Attributes:

       id                   INTEGER UNIQUE

       producer_id          LOCAL STRING(20)

       persistent_id        LOCAL STRING(60)

       persid               SREL -> cr.persistent_id

       string1              STRING(250)

       last_mod_dt          DATE ON_CI {NOW}

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



  • 8.  Re: Create custom button on SDM
    Best Answer

    Posted Feb 16, 2016 10:10 AM

    Ok, for this you don't need any buttons, a normal field like with any SREL cr->cnt will do. Have the spel trigger create the zdemand and add the field on the detail_cr.htmpl. You can even create a simple PDM_IF if you want to make sure it's not edited when in edit mode. The detail_cr.htmpl will have plenty of examples how to achieve this.



  • 9.  Re: Create custom button on SDM

    Posted Feb 16, 2016 10:16 AM

    Jussi thanks for your answer. Im so new on this, but when i put the field on the form like:

     

    <PDM_MACRO name=dtlReadonly hdr="zdemand" attr=zdemand.string1>

     

    the value is displayed on the form (detail_cr.htmpl) but when i change the value and save, the changes are lost.



  • 10.  Re: Create custom button on SDM

    Posted Feb 17, 2016 01:34 AM

    Yea, there's a tiny difference between what you tried and what will work. While the save to another object will not work like you attempted, showing the details of that object the "standard" way will work. Below are your line and my suggestion next to eachother for easier comparison, but I see you managed to solve the issue with another macro so all is good.

    <PDM_MACRO name=dtlReadonly hdr="zdemand" attr=zdemand.string1>
    <PDM_MACRO name=dtlLookup hdr="Gestión de la Demanda" attr=zdemand>

    If you want to make it a link on read mode and read-only on edit mode you can wrap it inside a PDM_IF like this:

    <PDM_IF "$prop.form_name_3" == "edit">
    <PDM_MACRO name=dtlReadonly hdr="Gestión de la Demanda" attr=zdemand>
    <PDM_ELSE>
    <PDM_MACRO name=dtlLookup hdr="Gestión de la Demanda" attr=zdemand>
    </PDM_IF>

    The built-in forms are a nice starter when you are learning how to do stuff but they'll only take you so far, after that it's up to your personal interest how deep you want to dig and how fancy magic you want to attempt while knowing you're beyond CA's support. Sometimes you just gotta do what you gotta do



  • 11.  Re: Create custom button on SDM

    Posted Feb 16, 2016 10:26 AM

    I resolve this using:

     

    <PDM_MACRO name=button Caption="Gestión de la Demanda..." Func="showDetailWithPersid('zdemand:$args.zdemand.id')" hotkey_name="Find Similar" ID=FIND_SIMILAR Tooltip="Buscar similar">

     

    The function showDetailWithPersid() open a new window with the related zdemand obj. I can edit without problems.

     

    Thanks to Jussi Valkonen



  • 12.  Re: Create custom button on SDM

    Posted Feb 16, 2016 10:01 AM

    Hi Aebmknrl,

     

    If I don't mis understand you, you can construct this URL in detail_cr.htmpl like this

     

    Javascipt Code;

     

    url="$cgi?SID=$SESSION.SID+FID="+fid_generator()+"+FACTORY=zdemand+ID="+$args.zdemand.id+"+OP=UPDATE+HTMPL=detail_zdemand.htmpl"; 
    ImgBtnCreate("btn100", "Update zdemand", "popupActivityWithURL('"+url+"')", true, 0);
    

    I hope it's your need

     

    Regards,

     

    Türker