Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

Adding lookup on contract class extension

(0) ShareShare
ReportReport
Posted on by 76

Hi, 

I'm trying to extend SAFT Report by a multi select lookup parameter. I did add a list in extended contract class, yet the lookup shows with no options to pick.

What is might be the problem here?

[
DataContractAttribute,
SysOperationContractProcessingAttribute(classStr(SAFTReportSZMUI))
]
[ExtensionOf(classStr(SAFTReportContract_Base_W))]
final class SAFTReportContract_Base_W_SZM_Extension
{
    private NoYes selectedWH;
    private List multiLocationId;

    [
        DataMember('Czy zakolejkować magazyny?'),
        SysOperationGroupMember('Warehouse'),
        SysOperationDisplayOrder('2')
    ]
    public NoYes parmSelectedWarehouses(NoYes _selectedWH = selectedWH)
    {
        selectedWH = _selectedWH;
        return selectedWH;
    }

    [
        DataMember('WarehouseMultiselect'),
        SysOperationGroupMember('Warehouse'),
        SysOperationDisplayOrder('3'),
        AifCollectionType('WarehouseMultiselect', Types::String, extendedTypeStr(InventLocationId))
    ]
    public List parmInventLocationIdMulti(List _multiLocationId = multiLocationId)
    {
        multiLocationId = _multiLocationId;
        return multiLocationId;
    }

}

class SAFTReportSZMUI  extends SysOperationAutomaticUIBuilder
{
    FormStringControl custGroupRecIdsControl;
    #define.InventLocationIdName('InventLocationIdControl')

    public void postRun()
    {
        SysOperationDialog  reportDialog;

        reportDialog = this.dialog();
        custGroupRecIdsControl = dialog.formRun().design().addControl(FormControlType::String, #InventLocationIdName);
        custGroupRecIdsControl.visible(false);
    }

    public void build()
    {
        SAFTReportContract_Base_W   contract;
        DialogField                             dialogField;

        contract = this.dataContractObject() as SAFTReportContract_Base_W;
        dialogField = this.addDialogField(methodStr(SAFTReportContract_Base_W, parmInventLocationIdMulti), contract);
    }

    public void postBuild()
    {
        DialogField                             dialogField;
        SAFTReportContract_Base_W                contract;
        ;

        super ();
        contract    = this.dataContractObject();

        dialogField = this.bindInfo().getDialogField(this.dataContractObject(), methodstr(SAFTReportContract_Base_W, parmInventLocationIdMulti));
        dialogField.registerOverrideMethod(methodstr(FormStringControl, lookup), methodstr(SAFTReportSZMUI, custGroupIdLookup), this);
    }

    protected void custGroupIdLookup(FormStringControl _control)
    {
        Query                       query;
        QueryBuildDataSource        qbds;
        SysLookupMultiSelectGrid    lookup;
        container                   selectedFields;

        query   = new Query();
        qbds    = query.addDataSource(tableNum(InventLocation));
        qbds.addSelectionField(fieldNum(InventLocation, InventLocationId));
        qbds.addSelectionField(fieldNum(InventLocation, Name));
        qbds.addSelectionField(fieldNum(InventLocation, InventSiteId));


        selectedFields = [tableNum(InventLocation), fieldNum(InventLocation, InventLocationId)];
        lookup = new SysLookupMultiSelectGrid();
        lookup.parmCallingControlStr(_control);
        lookup.parmCallingControl(_control);
     //   lookup.parmCallingControlId(custGroupRecIdsControl);
        lookup.parmSelectField(selectedFields);
        lookup.parmQuery(query);
        lookup.run();
    }

}

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Adding lookup on contract class extension

    Extends is something related to inheritance concept where you will extend the class and override its method.

    ExtensionOf will keep the original code and add your custom code on top or bottom of it.

    Also, if you are duplicating the contract class don't extend the standard contract class.

    Thanks,

    Girish S.

  • RadekM Profile Picture
    RadekM 76 on at
    RE: Adding lookup on contract class extension

    I was looking on the classes, there are many entensions for different region and I found one that includes a UI builder. So does that mean that you actually can add UI builder in a extension?

    What is the difference in using extends over ExtensionOf?

    [

       DataContract,

       SysOperationGroup('Period', "@SYS40", '1'),

       SysOperationGroup('ExportAll', "@StandardAuditFile_SAFT_W:ExportAll", '2'),

       SysOperationGroup('Export', "@SYS26056", '3'),

       SysOperationGroup('ContactPerson', "@SYS325541", '4'),

       SysOperationContractProcessing(classStr(SAFTReportUIBuilder_Standard_W))

    ]

    internal class SAFTReportContract_Standard_W extends SAFTReportContract_Base_W

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Adding lookup on contract class extension

    If using the standard base contract works means - You still need to do some changes in the duplicated class - May be some class is still pointing to standard contract class instead of your duplicated class. Try double check that one.

    Thanks,

    Girish S.

  • RadekM Profile Picture
    RadekM 76 on at
    RE: Adding lookup on contract class extension

    The error is in the controller class. Only when I use the duplicated base contract. If I use the standard contract even with the extended fields it works.

    I have nothing added yet, the classes are only duplicated just changed the names when calling them.

    The init query is a standard method that creates an initial query. The method is called from the controller class.

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Adding lookup on contract class extension

    In which class its throwing error?

    Is it in DC class?

    What is the purpose of initQuery here?

    Is this available in standard or your customization?

    Thanks,

    Girish S.

  • RadekM Profile Picture
    RadekM 76 on at
    RE: Adding lookup on contract class extension

    Okay so i duplicated the contract, controller now I have a error that the contract is null. If i use the old one its fine.

    The error occours here.

     private void initContract()
        {
            if( !xSysLastValue::getLast(this))
            {
                SAFTReportContract_Base_W_SZM contract = this.getDataContractObject() as SAFTReportContract_Base_W_SZM;
                contract.initQuery();
            }
        }
    
    
    [
        DataContract,
        SysOperationGroup('Period', "@SYS40", '1'),
        SysOperationGroup('ExportAll', "@StandardAuditFile_SAFT_W:ExportAll", '2'),
        SysOperationGroup('Export', "@SYS26056", '3'),
        SysOperationGroup('ContactPerson', "@SYS325541", '4'),
        SysOperationGroup('TaxAuthority', "@SYS21937", '5'),
        SysOperationGroup('SubmittingPurpose', "@StandardAuditFile_SAFT_W:SubmittingPurpose", '6'),
        SysOperationGroup('Warehouse', "@SYS6437", '7'),
        SysOperationGroup('ReportingParameters', "@StandardAuditFile_SAFT_W:ReportingParameters", '8'),
        DataContractAttribute,
        SysOperationContractProcessingAttribute(classStr(SAFTReportSZMUI))
    ]

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Adding lookup on contract class extension

    If there is no UI builder class on the standard report you cannot add that via extension. Its better to duplicate all the standard report objects and use that.

    Also if you add new parameters via extension its hard to add range to the DP class through extension. So its better to duplicate all report objects.

    Thanks, 

    Girish S.

  • RadekM Profile Picture
    RadekM 76 on at
    RE: Adding lookup on contract class extension

    No, or at least I didnt find any.

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Adding lookup on contract class extension

    Does the standard report have UI builder class?

    Thanks,

    Girish S.

  • RadekM Profile Picture
    RadekM 76 on at
    RE: Adding lookup on contract class extension

    I tried but the UI buider is not being hit.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans