web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Adding lookup on contract class extension

(0) ShareShare
ReportReport
Posted on by 170

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();
    }

}

I have the same question (0)
  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Adding lookup on contract class extension

    Hi Radek,

    Have you debugged the code?

    Does the UI Builder class got hit?

    Thanks,

    Girish S.

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

    I tried but the UI buider is not being hit.

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Adding lookup on contract class extension

    Does the standard report have UI builder class?

    Thanks,

    Girish S.

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

    No, or at least I didnt find any.

  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator 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
    170 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))
    ]

  • GirishS Profile Picture
    27,825 Moderator 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
    170 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
    27,825 Moderator 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
    170 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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 724 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 580 Most Valuable Professional

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 554

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans