IFS Mobile Development (MWO) - Customization


Add sync entities to the app

Below I'm explaining customizing of ServiceEngApp but it will be same for the MaintEngApp as well.

Customize ServiceEngApp (.app) file to add your entities (new entities) like below to enable sync capabilities and you can control app settings like GPS Tracking, Multi Device etc.

File Name: ServiceEngApp-Cust.app

@Override
settings {
   errorhandling Server;
   pinauthentication Enabled;
   gpstracking Enabled;
   multidevice Enabled;
}

@Override
syncentities {
   entity CPartOrder {
      offlinewhere = "Objstate in ('Planned', 'Released', 'Completed')";
      transactiongroup = "C Part Order:${PartOrderId}";
      syncpolicy Batch {
         syncschedule = daily at 00:00;
      }
   }
   entity CPartOrderLine {
      transactiongroup = "C Part Order Line:${PartOrderId}-${LineNo}";
      syncpolicy Batch {
         syncschedule = daily at 00:00;
      }
   }
}

Transaction Grouping:

Transaction Grouping is used in Failed Transaction handling to only block transactions from a single business object when a failure occurs rather than blocking all transactions from the User/Device/Application. 

Sync Policies:

There are 3 sync policies you can use in your entity.

Batch - Batch entities are synchronized on a schedule and processed by a Database Task. The Synchronization Rules are created with a default schedule, but this can be overridden by using the command Edit Sync Rules.

Push and Batch - Push and Batch entities are synchronized in a similar way to Batch entities with an addition of pushing data changes to the users.

Grouped Push - Grouped Push entities are used to synchronize the same set of data to a group of users. The data is collected the first time a user within a group connects with the mobile app. When another user within the same group connects the collected data is synchronized to the user (plus any subsequent changes to the collected data).

Customize core client/projection files

Here it will generate below new files. There you can write your customization codes.

ServiceEngApp-Cust.client
ServiceEngApp-Cust.projection
ServiceEngApp-Cust.plsvc
ServiceEngApp-Cust.offline

In this .client/.projection/.plsvc file you can write your normal Aurena functionalities based on your requirement. As a example you can add your pages, groups, lists, assistants etc. (Note: some of the features may not be available on mobile. e.g: tabs)

Make sure to add offline capabilities to your cust projection. use below code snippets for that.

File Name: ServiceEngApp-Cust.projection

projection ServiceEngApp;
component MWO;
layer Cust;
capability Offline;
category Users, NativeMobile;

Make sure to add target type to the cust client.

File Name: ServiceEngApp-Cust.client

client ServiceEngApp;
component MWO;
layer Cust;
description "Put some useful description here ...";
target AurenaNative;

Can use below core method to identify the client. Will be useful when doing changes.

variable StateOnline;

call GetCurrentClient() into StateOnline; 
 if[StateOnline = "OFFLINE"] {
       //Mobile
}
 if[StateOnline = "ONLINE"] {
       //IFS Cloud
 }


Offline File

Generated cust offline file can be used to write functions and procedures which can be trigged when the device is out of coverage. Below I have added some of useful examples needed when implementing changes.

Return a Filtered List:

@Overtake Core
procedure Function<CGetAssiginedPartOrderLines> List<Structure(CPartOrderLine)> {
   parameter PartOrderId Number;
   parameter Result List<Structure(CPartOrderLine)>;
   variable  CPartOrderLineRec Structure(CPartOrderLine);
   execute {
      for CPartOrderLineSet l where [l.PartOrderId = PartOrderId] into CPartOrderLineRec {
         call List.Add(Result, CPartOrderLineRec);
      }
      return Result;
   }
}

Return a Count:

procedure Function<CCountPartOrders> Number {
   variable Result Number;
   variable  CPartOrderRec Structure(CPartOrder);
   variable  Orders List<Structure(CPartOrder)>;
   execute {
      for CPartOrderSet l into CPartOrderRec {
         call List.Add(Orders, CPartOrderRec);
      }

      call List.Count(Orders) into Result;
      return Result;
   }
}

Change Status:

In here make sure to use performAction; code snippet, otherwise changes will stay on local will not be transfered to the IFS Cloud end.

@Override
procedure Action<CPartOrder.SetReleased> {
   execute {
      super(Record);
      performAction;

      set Record.Objstate = "Released";
      saveLocal Record;
   }
}

 Create a New Record:

@Overtake Core
procedure Action<CSaveRecord> Number {
   parameter Description Text;
   parameter Contract Text;
   parameter Destination Text;
   parameter CustomerNo Text;
   parameter ServiceObject Text;
   parameter Priority Text;
   parameter InternalNotes Text;
   parameter Address Text;
   parameter CreatedBy Text;
   parameter CreatedDate Timestamp;

   parameter Result Number;
   variable MaxId Number;
   variable  CPartOrderRec Structure(CPartOrder);
   execute {

      fetch CPartOrderSet orderby [PartOrderId desc] into CPartOrderRec;
      set MaxId = [CPartOrderRec.PartOrderId+1];

      set CPartOrderRec = null;
      create CPartOrderRec;

      set CPartOrderRec.PartOrderId = MaxId;
      set CPartOrderRec.Description = Description;
      set CPartOrderRec.Contract = Contract;
      set CPartOrderRec.Destination = Destination;
      set CPartOrderRec.CustomerNo = CustomerNo;
      set CPartOrderRec.ServiceObject = ServiceObject;
      set CPartOrderRec.Priority = Priority;
      set CPartOrderRec.InternalNotes = InternalNotes;
      set CPartOrderRec.Address = Address;
      set CPartOrderRec.CreatedBy = CreatedBy;
      set CPartOrderRec.CreatedDate = CreatedDate;
      set CPartOrderRec.Objstate = "Planned";

      saveAndSend CPartOrderRec;


      set Result = MaxId;

      return Result;
   }
}

Delete a Record:

@Overtake Core
procedure Action<CRemoveLine> {
   parameter PartOrderId Number;
   parameter LineNo Number;
   variable  CPartOrderLineRec Structure(CPartOrderLine);
   execute {
      for CPartOrderLineSet l where [l.PartOrderId = PartOrderId and l.LineNo = LineNo] into CPartOrderLineRec {
         deleteAndSend CPartOrderLineRec;
      }
   }
}


Useful Links

Link to the icon library:
<ROOT>/main/ifsapplications/web/iconlibrary

Internal app download page:
https://mass.ifsworld.com/mass/ifsaurenanative/

Video Summary




Post a Comment

0 Comments