Sunday, 13 August 2017

How to create Conditional Fields in IBM Anywhere?

How to create Conditional Fields in IBM Anywhere?

This article explains the steps to make a field mandatory based on a condition. 

Requirement:

For a workorder, when the status has been changed to Hold from another status, the “Memo” field should become mandatory and if the memo field is not filled then app should throw an error message. For the other statuses “Memo” field is not mandatory.






Solution:

To implement the above requirement you need to specify an event handler in the app.xml file to make the “Memo” field mandatory which depends on value of status field selected by mobile user.

   1.     Open the app.xml for the app that you want to update and make the following changes
a.     Add the custom message to show when the “Memo” field is empty

<messages id="messages">
<message defaultMessage="Please fill in the Memo Field" id="MemoValidation"/>
</messages>

b.    In the Status Change Container of the  app.xml, add a Validate type of event handler to the “New Status” field
                                          i.    In the <text> element of the new field, add a child element named <eventHandlers>.
                                         ii.    In the <eventHandlers> element, add a child element named <eventHandler>.
                                        iii.    Specify Vaidate as the event attribute, and add the method and class attributes.

 <container id="WorkExecution.EditStatusView_statusChangeResource_container_0" resource="statusChangeResource">
                                                <group id="WorkExecution.EditStatusView_group_1">
                                                            <groupitem id="WorkExecution.EditStatusView_statusChangeResource_groupitem_0">
                                                                        <text editable="true" id="WorkExecution.EditStatusView_statusChangeResource_groupitem_0_changedate_StatusDate" label="Status Date" placeHolder="Select" required="true" resourceAttribute="changedate"/>
                                                            </groupitem>
                                                            <groupitem id="WorkExecution.EditStatusView_statusChangeResource_groupitem_1">
                                                                        <text editable="false" id="WorkExecution.EditStatusView_statusChangeResource_groupitem_1_statusdesc_NewStatus" label="New Status" lookup="WorkExecution.statusLookup" placeHolder="Select from list" required="true"  resourceAttribute="statusdesc">
                                                                                   
                                                                                    <eventHandlers id="WorkExecution.EditStatusView_statusChangeResource_groupitem_1_statusdesc_NewStatus_eventHandler">
                                                                                                <eventHandler class="application.handlers.StatusChangeHandler" event="validate" id="WorkExecution.EditStatusView_statusChangeResource_groupitem_1_statusdesc_NewStatus_eventHandlers_validate" method="makeMemoMandatory"/>
                                                                                    </eventHandlers>
                                                                                   
                                                                        </text>
                                                            </groupitem>
                                                            <groupitem id="WorkExecution.EditStatusView_statusChangeResource_groupitem_2">
                                                                        <text editable="true" id="WorkExecution.EditStatusView_statusChangeResource_groupitem_2_memo_Memo" label="Memo" placeHolder="Tap to enter" resourceAttribute="memo"/>
                                                            </groupitem>
                                                </group>
                                    </container>

            2.     Apply the condition for the event handler to StatusChangeHandler  javascript file or you can
                  create your own custom javascript file and add the below logic

makeMemoMandatory: function(eventContext){
                                 
                                  var workOrder=eventContext.getCurrentRecord();
                                  var statusChange = CommonHandler._getAdditionalResource(eventContext,"statusChangeResource").getCurrentRecord();
                                  var newStatus=statusChange.get("status");
                                  var currMemo = statusChange.get("memo");                                         
                                  if (newStatus == "HOLD" && currMemo == null){
                                                 var fieldMetadata = statusChange.getRuntimeFieldMetadata("memo");
                                                 fieldMetadata.set('required', true);                                                        
                                  }else if(newStatus !== "HOLD"){
                                                 var fieldMetadata = statusChange.getRuntimeFieldMetadata("memo");
                                                 fieldMetadata.set('required', false);
                                  }
                                 
                   }

       3.     Add the following code in commitWOStatusChange method of StatusChangeHandler.js to check   
             if the Memo field is empty or not

var currMemo = statusChange.get("memo");                                            
if (newStatus == "HOLD" && currMemo == null){
   throw new PlatformRuntimeException("MemoValidation");
}
                                           
 4.     Save your changes and preview the updated mobile app in a mobile browser simulator.




Friday, 30 May 2014

How to Translate Start Center Contents?



If you would like to translate the start center contents then you need to translate the following

  • Result Set Portlet Headings
  • Result Set Portlet Columns
  • Start Center Headings
Portlet Descriptions, "headings on portlets", are picked up from the LAYOUT table and the LAYOUT.DESCRIPTION field is merely LOCALIZABLE and MLSUPPORTED. These strings are picked from MAXLABELS or L_MAXLABELS. Below are the steps to translate the portlet headings.
INSERT INTO L_MAXLABELS(L_MAXLABELSID,LANGCODE,value,ownerid) SELECT L_MAXLABELSSEQ.NEXTVAL,<langcode>,<translated text>, MAXLABELSID FROM MAXLABELS WHERE VALUE LIKE <portlet heading> AND MAXLABELSID NOT IN (SELECT OWNERID FROM L_MAXLABELS WHERE OWNERID IN(SELECT MAXLABELSID FROM MAXLABELS WHERE VALUE LIKE <portlet heading> ) and langcode=<langcode>);

Result set columns are available in RSCONFIG table. Translation for RSCONFIG.DESCRIPTION retrieved from 
maxattribute/l_maxattribute table. So you don’t need to do the translation separately for RSCONFIG.DESCRIPTION if the 
translation is available in l_maxattribute.
 
Start Center Descriptions, "headings on Startcenter", are picked up from the SCTEMPLATE table and the SCTEMPLATE.DESCRIPTION. These strings are picked from MAXLABELS or L_MAXLABELS. Below is the script to translate the start center headings.
 
INSERT INTO L_MAXLABELS(L_MAXLABELSID,LANGCODE,value,ownerid) SELECT L_MAXLABELSSEQ.NEXTVAL,<langcode>,<translated text>, MAXLABELSID FROM MAXLABELS WHERE VALUE LIKE <SC Template heading> AND MAXLABELSID NOT IN (SELECT OWNERID FROM L_MAXLABELS WHERE OWNERID IN(SELECT MAXLABELSID FROM MAXLABELS WHERE VALUE LIKE <SC Template heading> ) and langcode=<langcode>);
 
Start center template needs to be updated after modifying the start center contents. 
 
First of all you have to identify the set of start centers to be reset. In this example I want to reset all the start centers 
of the user's belonging to SECGROUP security group. Run this select and check the results. 

DELETE FROM rsconfig WHERE layoutid IN (SELECT layoutid FROM layout WHERE scconfigid IN (SELECT scconfigid FROM scconfig WHERE groupname='SECGROUP'));
DELETE FROM faconfig WHERE layoutid IN (SELECT layoutid FROM layout WHERE scconfigid IN (SELECT scconfigid FROM scconfig WHERE groupname='SECGROUP'));
DELETE FROM inbxconfig WHERE layoutid IN (SELECT layoutid FROM layout WHERE scconfigid IN (SELECT scconfigid FROM scconfig WHERE groupname='SECGROUP'));
DELETE FROM kpilconfig WHERE layoutid IN (SELECT layoutid FROM layout WHERE scconfigid IN (SELECT scconfigid FROM scconfig WHERE groupname='SECGROUP'));
DELETE FROM kpigconfig WHERE layoutid IN (SELECT layoutid FROM layout WHERE scconfigid IN (SELECT scconfigid FROM scconfig WHERE groupname='SECGROUP'));
DELETE FROM actionscfg WHERE layoutid IN (SELECT layoutid FROM layout WHERE scconfigid IN (SELECT scconfigid FROM scconfig WHERE groupname='SECGROUP'));
DELETE FROM portletdisplay WHERE layoutid IN (SELECT layoutid FROM layout WHERE scconfigid IN (SELECT scconfigid FROM scconfig WHERE groupname='SECGROUP'));

DELETE FROM layout WHERE layoutid IN (SELECT layoutid FROM layout WHERE scconfigid IN (SELECT scconfigid FROM scconfig WHERE groupname='SECGROUP'));

DELETE FROM scconfig WHERE scconfigid IN (SELECT scconfigid FROM scconfig WHERE groupname='SECGROUP');

When the user either logs in or returns to the start center, the system will rebuild the start center from the appropriate template that was updated.

Wednesday, 7 May 2014

System properties to control the left navigation pane in SCCD 7.5

There are four System Properties introduced in SmartCloud Control Desk 7.5 which control the left navigation pane and other related visual attributes:
mxe.webclient.homeButtonHeaders
Navigator: Moves Goto menu to left of the screen and adds Start Center button to the header

mxe.webclient.systemNavBar
Navigator: Enables the lefthand navigation

mxe.webclient.tabBreadCrumbs
Navigator: Removes tabs from list view

mxe.webclient.verticalLabels
Navigator: Sets label above each input field

Monday, 2 September 2013

IBM Maximo 7.5 Customization Detection Tool

Do you need a quick way to determine what customizations you’ve made to your Maximo7.5 ?

If so, check out the Customization Detection tool. The tool provides information about customizations for business objects, field classes, and services that were customized (extended/added) for the out-of-the-box system. It does not provide information about UI bean classes or other configuration changes.

The tool currently works on Maximo Asset Management Version 7.5.0.0 and higher.

You can download the tool via the Integrated Service Management (ISM) Library.

https://www-304.ibm.com/software/brandcatalog/ismlibrary/details?catalog.label=1TW10MA4S