CA Service Management

How to create custom BREL/QREL/LREL attribute 

Jul 21, 2015 08:54 AM

    Introduction

In continuation of CA Service Desk - Create a new table - out-of-box by TMACUL,

I wish to explore one of common questions : how to create many-to-many relation in CA SDM.

We have possibility to use 3 kind of relations :

  • BREL
  • LREL
  • QREL

All of them are declared as:

This field type should be selected only on direction from a CA employee.

@ Web Screen Painter Help

       

Which don't provide any useful information for us.

( except that incorrect definition can crash the entire system )

 

But sometimes business don't give us another choice than use that kind of relations.

 

Before we start, I wish to apologize that some of paragraphs were written carelessly,

so if you are ready to publish list relations you should know schema modification basics.

 

    BREL

Many to many relation, which designed to create each object manually.

Attribute is used to define relation between compound objects,

where one or more attribute could be assigned while creation.

 

Example:

We want to add additional workflow tasks to Change Order Category.

(this example is a part of our environment, where CO WF automatically adds to CO if some conditions are met)

 

Schema (WSP)

    z_ext_wf (TABLE)

          task SREL tsksty;

          sequence INT;

          chgcat SREL chgcat;

          org SREL org; // here is condition, if CO requestor's organization equals this, wf will be inserted;

 

    chgcat (OOTB TABLE)

          z_ext_wfs BREL z_ext_wf;

          BREL Query Information (Advanced tab):

              chgcat DYNAMIC {

                    DOMSET MLIST_DYNAMIC;

              }

 

How it looks:

BREL.png

 

Forms (HTMPL)

To operate new table, 2 form are required:

  • list - to perform search;
  • detail - to display details;

 

I recommend to use OOTB templates, could be found in $NX_ROOT\bopcfg\www\htmpl\web\analyst\.

Also have attached them to this doc.

 

Rename files to list_z_ext_wf.htmpl and detail_z_ext_wf.htmpl;

 

Modify list file:

  1.     Open list_z_ext_wf.htmpl
  2.     Go to line 26 : <PDM_MACRO NAME=sfStart factory="&{factory}">
  3.     Modify line 26 to <PDM_MACRO NAME=sfStart button=false factory="z_ext_wf">
  4.     Add js function to head area:
var enableExtraBtn = true;
cfgExtraButton = new Array("Create New", "zCreateNew()", enableExtraBtn);
function zCreateNew() {
  create_new('z_ext_wf',0,0,0,'PRESET=chgcat:'+ahdframe.argCode,'INITFROM=frm002');
}
      

    5.    Add columns to the list:

<PDM_MACRO name=lsCol hdr="Sequence" attr="sequence" link=yes sort="isscat ASC">
<PDM_MACRO name=lsCol hdr="Task" attr="task">
<PDM_MACRO name=lsCol hdr="Organization" attr="org">
      

 

Modify detail file:

    1.    Open detail_z_ext_wf.htmpl

    2.    Define factory as z_ext_wf in dtlForm macro

    3.    Add decided attrs between dtlStart and dtlEndTable tags

 

Modify detail_chgcat.htmpl:

    1.    Open detail_chgcat.htmpl for decided form group

    2.    Add new tab between startNotebook and endNotebook tabs:

<PDM_MACRO name=TAB title="Additional workflows" height=600 id=ext_wfs src="OP=SEARCH+FACTORY=z_ext_wf+QBE.EQ.chgcat=$args.code">
      

    3.    Add category code to head area (to make zCreateNew function preset work):

var argCode = "$args.code";
      

 

Finalization

Now publish schema.

Apply changes.

Do other stuff.

 

 

    LREL

List Relation is very similiar to BREL but it's used only to create relation between two factories.

Sure it relation could have any kind of options but all of them will be lost if relation will changed.

 

Example:

We make the same example, we want to use extended workflow tasks, but now all of them are predefined and not linked to any Change Category.

 

Schema (WSP):

    z_ext_wf (TABLE)

          task SREL tsksty;

          sequence INT;

          org SREL org; // here is condition, if CO requestor's organization equals this, wf will be inserted;

          chgcats BREL z_ext_wf_lrel;

          BREL Query Information (Advanced tab):

              wf {

                    LREL chgcat;

              }

 

    z_ext_wf_lrel (TABLE)

          wf SREL z_ext_wf;

          chgcat SREL chgcat;

 

    chgcat (OOTB TABLE)

          z_ext_wfs_lrel BREL z_ext_wf_lrel;

          BREL Query Information (Advanced tab):

              chgcat {

                    LREL wf;

              }

 

Forms (HTMPL):

Forms will be the same as BREL, we only need to replace Creation function with Update lrel one. (in list form)

var enableExtraBtn = true;
cfgExtraButton = new Array("Update LREL", "zCreateNew()", enableExtraBtn);
function zCreateNew() {
  update_with_lrel_style('chgcat', ahdframe.argPersistentID, 'z_ext_wf', 'z_ext_wfs_lrel',  'Found WFs', 'Assigned WFs', '');
}
  

Oh, tab on deatil_chgcat should be modified too:

<PDM_MACRO name=TAB title="Additional workflows" height=600 id=ext_wfs src="OP=SEARCH+FACTORY=z_ext_wf+KEEP.where_clause=chgcats.chgcat IN '$args.code'">
  

 

Please notice: If you're using custom factory you need to manually define correct form to perform and show search results as LREL.

Add followed code to list which is used to search data for LREL, this could should be pasted between sfStart and sfEnd tags.

<PDM_IF "$args.KEEP.forLREL" == "1">
document.writeln('<INPUT TYPE=hidden NAME=HTMPL VALUE=update_lrel_z_factory.htmpl>');
</PDM_IF>

also you need to pass that attribute over your update lrel button:

update_with_lrel_style('chgcat', ahdframe.argPersistentID, 'z_ext_wf', 'z_ext_wfs_lrel',  'Found WFs', 'Assigned WFs', '', 'KEEP.forLREL=1');

update_lrel form is attached to this, it could be used without any modifications, simply define correct name, my suggestion is to call it update_lrel_<custom_factory>.htmpl.

 

 

    QREL

I really don't know why this type of attr is exists,

as I found it can be used only in SPEL macros and easily can be replaced via this code:

send_wait(0, top_object(), "call_attr", factory, "sync_fetch", "STATIC", format("HERE IS THE SAME QUERY"), -1, 0);
msg[1]; // array length
 

 

Schema (WSP)

     cnt (TABLE)

          z_QREL QREL cr;

          Active QREL Query Information:

               DYNAMIC {

                    WHERE customer = ?;

                    PARAM_NAMES id;

               }

 

Usage

create spel macro with followed code:

logf(SIGNIFICANT, "%d", z_QREL.length); // will display amount of Requests where current contact is a customer.

 

Also could be used on List forms to display amount of matching records:

<PDM_MACRO name=lsCol hdr="Some attr count" attr="some_obj.childs" display_attr=length>

Statistics
0 Favorited
82 Views
3 Files
0 Shares
3 Downloads
Attachment(s)
zip file
detail.template.zip   770 B   1 version
Uploaded - May 29, 2019
zip file
list.template.zip   880 B   1 version
Uploaded - May 29, 2019
zip file
update_lrel_z_factory.htmpl.zip   2 KB   1 version
Uploaded - May 29, 2019

Related Entries and Links

No Related Resource entered.