Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

sysoperation framework add dialog field based on the enum parameter of the menuitem which launched the report

Posted on by 763

Hello,

I'm trying to edit SSRS report based on the sysoperation framework. The report is launched from menu item with the particular parmenum parameter. If the report is launched from such menuitem I need to add a new dialog field to my dialogform which also must change the original order of the dialog fields. It should be inserted between 3rd and 4rd fields. Which approach should be followed in that case? I have added a new parm method to my contract class for my new dialog field and marked it as invisible because it should appear only in circumstances described above (I hope it's correct):

 

[
    DataMemberAttribute(),
    SysOperationGroupMemberAttribute('Parameters'),
    SysOperationDisplayOrderAttribute('3'),
    SysOperationLabelAttribute(literalstr("@SYS54971")),
    SysOperationHelpTextAttribute(literalstr("@SYS54971")),
    SysOperationCtrlAllowEditAttribute_ICL(false),
    SysOperationControlVisibilityAttribute(false)
]
public TransDate parmActivationDate(TransDate _activationDate = activationDate)
{
    activationDate = _activationDate;

    return activationDate;
}

Any help would be much appreciated. Thanks.

  • dark_knight Profile Picture
    dark_knight 763 on at
    RE: sysoperation framework add dialog field based on the enum parameter of the menuitem which launched the report

    Solved. Thank you:)

  • dark_knight Profile Picture
    dark_knight 763 on at
    RE: sysoperation framework add dialog field based on the enum parameter of the menuitem which launched the report

    Tried. The same problem. Also when I debug my dialog field dlgActivationDate after the string

    dlgActivationDate           = this.bindInfo().getDialogField(contract, methodStr(ProdCalculation_Contract_ICL, parmActivationDate));

    Contains null value. Why it is so?

    Thanks.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 224,528 Super User on at
    RE: sysoperation framework add dialog field based on the enum parameter of the menuitem which launched the report

    It's probably because of SysOperationControlVisibilityAttribute. Remove the attribute and set visible(false) in code when needed.

  • dark_knight Profile Picture
    dark_knight 763 on at
    RE: sysoperation framework add dialog field based on the enum parameter of the menuitem which launched the report

    Hello Martin,

    Thank you very much for your answers. I have created a new parmMethod for my new field in contract class like that:

    [
        DataMemberAttribute(),
        SysOperationGroupMemberAttribute('Parameters'),
        SysOperationDisplayOrderAttribute('4'),
        SysOperationLabelAttribute(literalstr("@SYS54971")),
        SysOperationHelpTextAttribute(literalstr("@SYS54971")),
        SysOperationCtrlAllowEditAttribute_ICL(false),
        SysOperationControlVisibilityAttribute(false)
    ]
    public TransDate parmActivationDate(TransDate _activationDate = activationDate)
    {
        activationDate = _activationDate;
    
        return activationDate;
    }

    I have pointed it as invisible by default.

    Then I have added the following code to classDeclaration of my the class UIBuilder:

    DialogField                             dlgActivationDate;

    then to postbuild() method of UIBuilder:

    dlgActivationDate           = this.bindInfo().getDialogField(contract, methodStr(ProdCalculation_Contract_ICL, parmActivationDate));
        if(contract.parmIsLaunchedFromBaseData() == IsLaunchedFromBaseData::IsLaunchedFromBaseData)
        {
            dlgActivationDate.visible(true);
            dlgActivationDate.allowEdit(false);
        }

    The system throws error on the string:

    dlgActivationDate.visible(true);

    saying that dialogfield object isn't initialized.

    What's wrong wth the code?

    Thanks.

  • Martin Dráb Profile Picture
    Martin Dráb 224,528 Super User on at
    RE: sysoperation framework add dialog field based on the enum parameter of the menuitem which launched the report

    You can use such an enum, if you want, but you need at least two values in the data contract (because you have two cases). You can use boolean, if you're sure that there won't be more cases, or use an enum that you can extend later. Possibly you can use the same enum as for the menu item, but then you need a second value there (for the default case).

    Regarding the UI builder, I would do it in postBuild(). You already set the order of fields by SysOperationDisplayOrderAttribute.

  • dark_knight Profile Picture
    dark_knight 763 on at
    RE: sysoperation framework add dialog field based on the enum parameter of the menuitem which launched the report

    Hello Martin,

    Thanks for the help. I have created enum with only one value and then I have pointed out the value of that enum in the properties of the menuitem. So it's something like the flag that report has been launched by this particular menitem. Maybe I did it wrong?

    Also which is the best place to handle visibility of the fields in UIBuilder class? Maybe "build" method? How to insert my fields between particular fields?

    Thanks.

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 224,528 Super User on at
    RE: sysoperation framework add dialog field based on the enum parameter of the menuitem which launched the report

    First of all, you need a data member that says which case it is. Populate this value in prePromptModifyContract() method of the controller, based on the enum parameter.

    In the UI builder, look at the new parameter to determine which variant of the UI you should use. Then you can manipulate visibility of ActivationDate.

Helpful resources

Quick Links

Can you answer this forum question?

You could make someone's day!

Community Newsletter - May 2024

Kudos to our community stars!

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,632 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 224,528 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans