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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Extension of formDataSource field

(0) ShareShare
ReportReport
Posted on by 1,552

Hi,

I did a duplicate of the standard field CategoryRecId in CaseDetailBase and i'm trying to call the same logic that gets called for it in CaseDetailForm -- but i'm getting errors

when doing this

[ExtensionOf(formDataFieldStr(CaseDetailCreate, CaseDetailBase, CaseCategoryRecIdCopy))]
final class CaseDetailCreateFormDataSourceField_Extension
{
    public Common lookupReference(FormReferenceControl _formReferenceControl)
    {
        next lookupReference(_formReferenceControl);

        return CaseDetailForm::lookupCategoryTree(_formReferenceControl, CaseDetailBase, categoryType);
    }
}


I'm getting those two errors:
pastedimage1684707768877v1.png

And when doing this, I'm getting those errors:
[ExtensionOf(formDataFieldStr(CaseDetailCreate, CaseDetailBase, CaseCategoryRecIdCopy))]
final class CaseDetailCreateFormDataSourceField_Extension
{
    public Common lookupReference(FormReferenceControl _formReferenceControl)
    {
        next lookupReference(_formReferenceControl);

        Args                args;
        FormRun             formRun;
        
        args = new Args();
        args.name(formStr(CaseCategoryLookupCopy));
        args.record(caseDetailBase); //error on caseDetailBase

        if (categoryType)
        {
            CaseDetailForm::updateArgsFromCategoryType(categoryType, args); // error here

            args.parmEnumType(enumNum(CaseCategoryType));
            args.parmEnum(enum2int(categoryType));
        }
        
        formRun = classfactory.formRunClass(args);
        formRun.init();
        formRun.selectRecordMode(_formReferenceControl);
        _formReferenceControl.performFormLookup(formRun);
        formRun.wait();
        
        return formRun.selectRecordModeSelectedRecord();
    }
}


pastedimage1684707800629v2.png

what to do with the delegate method?

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi,

    Use element.CaseDetailBase to get the current record. Also, for getting the categorytype there is a parm method on form method parmCategoryType - Use this method to get a category type.

    Thanks,

    Girish S.

  • junior AX Profile Picture
    1,552 on at

    Hi Girish,

    Do you mean element.parmCategoryType?

    How about the last error related to delegate method?

  • GirishS Profile Picture
    27,827 Moderator on at

    Yes, you need to use element type.

    I am not sure about that error. May be use of delegate call in extension is not possible in the context.

    Thanks,

    Girish S.

  • junior AX Profile Picture
    1,552 on at

    Hi Girish,

    But what to replace the delegate code with? As i'm duplicating what the standard does to get same result

  • GirishS Profile Picture
    27,827 Moderator on at

    Definition for this delegate method is available in CaseDetailFormEventHandler >> CaseDetailForm_updateCaseDetailQuery.

    You can try the logic as given in the method in your extension class.

    Thanks,

    Girish S.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 663 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 348 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans