How to do COC on Dialog field value on Class/CustVendOutPaym/dialogAddPrintDocument

Hello ,

I need to do a COC on method Class/CustVendOutPaym/dialogAddPrintDocument
In this method will create dialog fields and I have two radiobutton fields called Payment Advise and Use print management…

I need to make these two fields by default yes, but when I use COC and add below code
it is making them yes but it is also creating two more xtra controls beacuse in COC two fields and by standard logic another two

Below is the code used on COC, please suggest how to make these two runtime fields default yes

[ExtensionOf(classStr(CustVendOutPaym))]
final class FLTNA_PrintPaym_Extension
{

protected void dialogAddPrintDocument(PaymDocumentType  _documentType,
                                      DialogRunbase     _dialog,
                                      boolean           _addPrintOption,
                                      boolean           _makePrintGroup,
                                      boolean           _usePrintMgmt)
{
    next   dialogAddPrintDocument(_documentType,
                                        _dialog,
                                        _addPrintOption,
                                        _makePrintGroup ,
                                        _usePrintMgmt);

    VendParameters        vendParameters;
    DialogField           dialogPrintPaymAdvice;
    DialogField           dialogPrintPaymAdvicePrintMgmt;
    NoYes                 PaymadviseValue;

    select * from vendParameters where VendParameters.DataAreaId == curExt();
    

    if (vendParameters.UsePrintMgmtDefault)
    {
    
        switch (_documentType)
        {
        
            case PaymDocumentType::PaymAdvice:

               dialogPrintPaymAdvice = _dialog.addFieldValue(enumStr(NoYes), printPaymAdvice, "@SYS55191", "@SYS78930");

                if (_usePrintMgmt)
                {
                  dialogPrintPaymAdvicePrintMgmt = _dialog.addFieldValue(enumStr(NoYes), printPaymAdvicePrintMgmt, "@SYS70782", "@SYS70782");
                    if (dialogPrintPaymAdvice.value() == NoYes::No)
                    {
                        dialogPrintPaymAdvicePrintMgmt.enabled(false);
                    }
                }

                break;
        }
    }

}

}

The value is set in the second parameter of addFieldValue(). That’s the difference between addField() and addFieldValue() methods.

In your current code, you’re using variables printPaymAdvice and printPaymAdvicePrintMgmt, which you haven’t defined anywhere, therefore either your code doesn’t compile at all or you didn’t show us all the relevant code.

Anyway, if the value should always be initialized to Yes, you don’t need any variable. Simply set the static value there. For example:

_dialog.addFieldValue(enumStr(NoYes), NoYes::Yes, "@SYS55191", "@SYS78930");

Thanks Martin,

I tried that by passing Noyes::yes here my problem is is creating two more controls due to next keyword on COC and my custom code

dialogPrintPaymAdvice = _dialog.addFieldValue(enumStr(NoYes), Noyes:yes, “@SYS55191”, “@SYS78930”);

image

Please advise how to make them only two controls and default yes

My Complete custom code with COC as below
[ExtensionOf(classStr(CustVendOutPaym))]
final class FLTNA_PrintPaym_Extension
{

protected void dialogAddPrintDocument(PaymDocumentType  _documentType,
                                      DialogRunbase     _dialog,
                                      boolean           _addPrintOption,
                                      boolean           _makePrintGroup,
                                      boolean           _usePrintMgmt)
{
    next   dialogAddPrintDocument(_documentType,
                                        _dialog,
                                        _addPrintOption,
                                        _makePrintGroup ,
                                        _usePrintMgmt);

    VendParameters        vendParameters;       

    select * from vendParameters where VendParameters.DataAreaId == curExt();
    

    if (vendParameters.UsePrintMgmtDefault)
    {
    
        switch (_documentType)
        {
        
            case PaymDocumentType::PaymAdvice:

                dialogPrintPaymAdvice = _dialog.addFieldValue(enumStr(NoYes), NoYes:Yes, "@SYS55191", "@SYS78930");

                if (_usePrintMgmt)
                {
                    dialogPrintPaymAdvicePrintMgmt = _dialog.addFieldValue(enumStr(NoYes), NoYes::Yes, "@SYS70782", "@SYS70782");
                 
                
                    if (dialogPrintPaymAdvice.value() == NoYes::Yes)
                    {
                        dialogPrintPaymAdvicePrintMgmt.enabled(true);
                    }
                }

                break;
        }
    }

}

}

The above code creating two more extra radio button controls…Please advise
image

That you set the value directly instead of using a variable surely doesn’t add any extra form controls. It’s done by something else.

You can use the debugger to see where the fields come from. First of all, check which child of CustVendOutPaym you’re using at runtime; it’s likely that the fields are defined there. For example, CustOutPaym_Cheque.dialog() adds Bank account and From fields. There could also be another extension.

Hello Marting ,

I have debugged the code on COC method it is creating first two controls as Payment Advise & use Print management, it is because of code that existed as per the MS standard code
if (_makePrintGroup)
{
this.dialogAddPrintGroup(_dialog);
}

    switch (_documentType)
    {
        case PaymDocumentType::Document:
            dialogPrintDocument = _dialog.addFieldValue(enumStr(NoYes), printDocument, "@SYS101280", "@SYS78928");
            break;

        case PaymDocumentType::ControlReport:
            dialogPrintControlReport = _dialog.addFieldValue(enumStr(NoYes), printControlReport, "@SYS78925", "@SYS67272");
            break;

        case PaymDocumentType::AttendingNote:
            dialogPrintAttendingNote = _dialog.addFieldValue(enumStr(NoYes), printAttendingNote, "@SYS78926", "@SYS78929");
            break;

        case PaymDocumentType::PaymAdvice:

            dialogPrintPaymAdvice = _dialog.addFieldValue(enumStr(NoYes), printPaymAdvice, "@SYS55191", "@SYS78930");

            if (_usePrintMgmt)
            {
                dialogPrintPaymAdvicePrintMgmt = _dialog.addFieldValue(enumStr(NoYes), printPaymAdvicePrintMgmt, "@SYS70782", "@SYS70782");
                if (dialogPrintPaymAdvice.value() == NoYes::No)
                {
                    dialogPrintPaymAdvicePrintMgmt.enabled(false);
                }
            }

            break;
    }

I am using COC on method Class/CustVendOutPaym//dialogAddPrintDocument
This is the method which will create controls on runtime for print management

When I use the next dialogAddPrintDocument(_documentType,
_dialog,
_addPrintOption,
_makePrintGroup ,
_usePrintMgmt);

On top of it I did customization as below
[ExtensionOf(classStr(CustVendOutPaym))]
final class FLTNA_PrintPaym_Extension
{

protected void dialogAddPrintDocument(PaymDocumentType  _documentType,
                                      DialogRunbase     _dialog,
                                      boolean           _addPrintOption,
                                      boolean           _makePrintGroup,
                                      boolean           _usePrintMgmt)
{
    next   dialogAddPrintDocument(_documentType,
                                        _dialog,
                                        _addPrintOption,
                                        _makePrintGroup ,
                                        _usePrintMgmt);

    VendParameters        vendParameters;       

    select * from vendParameters where VendParameters.DataAreaId == curExt();
    

    if (vendParameters.UsePrintMgmtDefault)
    {
    
        switch (_documentType)
        {
        
            case PaymDocumentType::PaymAdvice:

                dialogPrintPaymAdvice = _dialog.addFieldValue(enumStr(NoYes), NoYes:Yes, "@SYS55191", "@SYS78930");

                if (_usePrintMgmt)
                {
                    dialogPrintPaymAdvicePrintMgmt = _dialog.addFieldValue(enumStr(NoYes), NoYes::Yes, "@SYS70782", "@SYS70782");
                 
                
                    if (dialogPrintPaymAdvice.value() == NoYes::Yes)
                    {
                        dialogPrintPaymAdvicePrintMgmt.enabled(true);
                    }
                }

                break;
        }
    }

}

}

here we can see dialog field dialogPrintPaymAdvice && dialogPrintPaymAdvicePrintMgmt initiated two times once in standard MS code and once in custom code

here I am not able to override existing field values of the controls dialogPrintPaymAdvice & dialogPrintPaymAdvicePrintMgmt

Okay, I’m slowly getting it.

You have code to add the same controls once more, but you don’t want that, therefore your code isn’t what you want. The solution of field duplication is throwing your code away.

Your actual requirement seems to be changing values of the existing fields; adding more fields was a mistake.

If you look at the standard code in dialogAddPrintDocument(), you can see that values of dialogPrintPaymAdvice and dialogPrintPaymAdvicePrintMgmt fields are defined by instance variables printPaymAdvice and printPaymAdvicePrintMgmt. All you need to do is changing values of these variables.

Hi Martin,

on the same method(dialogAddPrintDocument) I have written COC But I dont find which value to change …
After applying COC on dialogAddPrintDocument two more fields adding

And also I noticed that it is happening only when method of payment is Check for vendor payment journal

The two fields are added by your own code. Fix it by removing your code.

I also told you which variables to change: printPaymAdvice and printPaymAdvicePrintMgmt.

This is how you can change a value of a variable:

printPaymAdvice = NoYes::Yes;

Thanks Martin that duplication of fields issue sorted

This is default should happen only when the method of payment is Cheque…

I am looking at a Method class/VendOutPaym_Cheque/dialog()

Form where the method of class//CustVendOutPaym//dialogAddPrintDocument() getting called and setup the two radio button controls.

From here I could not find any parameter that can distinguish the method of payment is cheque or any other to pass to the method class//CustVendOutPaym//dialogAddPrintDocument()

To summarize it the two radio buttons should be default yes when the method class/CustVendOutPaym/dialogAddPrintDocument() called from class/VendOutPaym_Cheque/dialog()…any parameters or approach to achieve it

Thanks Martin,
This has been achived by writing COC on class/VendOutPaym_Cheque/dialog()

    DialogRunbase   dialog;
    printPaymAdvice = NoYes::Yes;
    printPaymAdvicePrintMgmt =   NoYes::Yes;
    
    //next  dialog();

   dialog =  next  dialog();
    return   dialog;

Yes, you don’t need any parameter. You just need to extend the class you want to change.