Skip to Content
0
Oct 29, 2021 at 05:07 PM

MDK - Object Table- OnSelectionChange Event - POST Entity

309 Views Last edit Oct 29, 2021 at 05:34 PM 4 rev

Hi Experts,

I have object table page(Assigned Employee) on Plus + button it opens up another Object list table(employee list) with MultiSelect, OnSelectionChange Event it add employee to my Assigned Employee Object table page , this work perfect but sometimes it duplicates the same record even though selection is different, i also need a way to check that already added records should not be added again.

Below is my code OnSelectionChange Event.

import libCommon from '../../../../SAPAssetManager/Rules/Common/Library/CommonLibrary';
import SplitID from '../../Common/GetLocalSplitID';

export default function SelectedAsignCreate(context) {
    let EmployeelistSection = context.getPageProxy().getControl('SectionedTable0').getSection('SectionObjectTable0');
    let selectedItems = [];
    selectedItems = EmployeelistSection.getSelectedItems();
    let operationAssign;
    for (let i = 0; i < selectedItems.length; i++) {
        let PersonnelNo = selectedItems[i].binding.PersonnelNumber; // if (!operationAssign.map(o => o.PersonnelNo).includes(PersonnelNo)) // {
        let EmpName = selectedItems[i].binding.EmployeeName;
        alert(PersonnelNo);
        libCommon.setStateVariable(context, 'PERNR', PersonnelNo);
        libCommon.setStateVariable(context, 'EmpName', EmpName);
        context.executeAction('/WDDDDASS/Actions/WorkOrders/Operations/ZSplitAssignment.action'); // operationAssign.push(PersonnelNo);
    }

}

Please suggest.

Bill Froelich

Regards

Manish