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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / How to extend dialog m...
Finance forum

How to extend dialog method of class using COC.

(0) ShareShare
ReportReport
Posted on by

Hi folks,

I have a need to ensure that collection letter field in dialog for create customer collection letter , show only 1 enum value out of all enum values for collectionlettercode.

Further analyzing i realized that the values are coming from public object Dialog() method of custcollectionlettercreate class & did change the following text in my extended class.

dialogCustCollectionLetterCode = dialogRunbase.addFieldValue(enumStr(CustCollectionLetterCode), collectionLetterCode, "@SYS13960") in orginal class to

dialogCustCollectionLetterCode = dialogRunbase.addFieldValue(enumstr(CustCollectionLetterCode::All)), collectionLetterCode, "@SYS13960"); in my extension class.

I tried customizing this class as per my need using COC, so i created class & enter the following code , but getting the following errors at red line

1. Not all path return value in dialog & 

2. ")" expected 

[ExtensionOf(classstr(CustCollectionLetterCreate))]
final class Myclass_CustCollectionLetterCreate_Extension
{
 
    public Object dialog()
    {
        next dialog();     
        dialogCustCollectionLetterCode = dialogRunbase.addFieldValue(enumstr(CustCollectionLetterCode::All)), collectionLetterCode, "@SYS13960");
    }

}

I understand that this method has to return object , however I cannot simply put a return code in my extension, please suggest how to do COC to address my requirement.

I have the same question (0)
  • Suggested answer
    BrandonSA Profile Picture
    1,677 on at

    Hi Mav

    I'm not sure what your requirement is, and whether your solution is correct or not, but this will help you resolve the immediate problem you have.

    What you should have is:

    [ExtensionOf(classstr(CustCollectionLetterCreate))]
    final class Myclass_CustCollectionLetterCreate_Extension
    {
     
        public Object dialog()
        {
            Object ret = next dialog();     
            dialogCustCollectionLetterCode = dialogRunbase.addFieldValue(enumstr(CustCollectionLetterCode::All)), collectionLetterCode, "@SYS13960");
    
            return ret;
        }
    
    }

    Hope this helps

  • Mav Profile Picture
    on at

    Thanks it does fix the return error , however still get 2nd error ")" expected

    Apparently enumstr would just accept enumstr name & not the enum:: value, pls suggest what needs to be done so that I can use enum :: value.

    dialogCustCollectionLetterCode = dialogRunbase.addFieldValue(enumstr(CustCollectionLetterCode::All)), collectionLetterCode, "@SYS13960");

  • Mav Profile Picture
    on at

    I think i understand it now.  

    We cannot add particular enum value to addfield. We have to limit the enum values being displayed in the dialog field by customizing Dialogenumcomboboxclass.

    I do have example of how to do it, however it is in Runbase & hence looking for sysoperations example , please share if anyone has already done this in sysoperation framework.

    Example of how to achieve this in Runbase framework is available in below community link.

    community.dynamics.com/.../244860

  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Addfieldvalue accept type not a value, so you have to pass enum. If you want only 1 value available what is the point at all ? Just make it not editable, pass "all" as a second parameter, so it would be defaulted, something like:

    dialogCustCollectionLetterCode = dialogRunbase.addFieldValue(enumstr(CustCollectionLetterCode)), CustCollectionLetterCode::All), "@SYS13960");

    dialogCustCollectionLetterCode.enabled(false)

  • Mav Profile Picture
    on at

    Hi

    I get the error  missing ";" at below red point.

    dialogCustCollectionLetterCode = dialogRunbase.addFieldValue(enumstr(CustCollectionLetterCode)), CustCollectionLetterCode::All), "@SYS13960");

    dialogCustCollectionLetterCode.enabled(false);

  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Yes, there is extra ")" should be like:

    dialogCustCollectionLetterCode = dialogRunbase.addFieldValue(enumstr(CustCollectionLetterCode), CustCollectionLetterCode::All,"@SYS13960");
    dialogCustCollectionLetterCode.enabled(false);


  • Sukrut Parab Profile Picture
    71,741 Moderator on at

    Remove one )

  • Mav Profile Picture
    on at

    Thanks for help.

    Sorry guys , i should have figured that out , my bad. 

    After fixing the bracket I am getting this error for dialogRunbase, should i declare another instance of dialog runbase  in my COC method.

    But if i do so will it work, i mean how will my dialogRubase instance in my coc relate to main dialogrubase instance in main class.

    Error The qualifier 'dialogRunbase' is not valid in this context. Use a variable of this type instead.

     dialogCustCollectionLetterCode = dialogRunbase.addFieldValue(enumstr(CustCollectionLetterCode),CustCollectionLetterCode::All,"@SYS13960");

           dialogCustCollectionLetterCode.enabled(false);

  • Suggested answer
    Sukrut Parab Profile Picture
    71,741 Moderator on at

    Well in Your COC method you must be getting dialog right ? something like this 

     

    ExtensionOf(classstr(bankChequeCreate))]
    Final class MybankChequeCreate_extension
    {
    	public Object dialog()
        {
            DialogRunbase dialog;
    
            Dialog = next Dialog();
    
            this.dialogBankTransType = dialog.addFieldValue(extendedTypeStr(BankTransactionType), bankTransType, "Trans Type");
    
            return Dialog;
        }
    }
  • Mav Profile Picture
    on at

    Hi all errors gone , using below code to do COC for dialog() for CustCollectionLetterCreate class.

    However

    Still see all values in drop down, as per code it should only show ALL, not sure why code is not working.

    Pls refer the pic below code.

     

    public Object dialog()
    
       {
    
           //object ret = next dialog();    
    
           DialogRunbase dialog;
    
           dialog = next Dialog();
    
           this.dialogCustCollectionLetterCode = dialog.addFieldValue(enumstr(CustCollectionLetterCode),CustCollectionLetterCode::All,"@SYS13960");
    
           dialogCustCollectionLetterCode.enabled(false);
    
           return dialog;    
    
       }

    ccreport.PNG

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans