Monday, October 4, 2021

SSRS file error message: The number of defined parameters is not equal to the number of cell definitions in the parameter panel (D365FO)

 Error

SSRS file error message: The number of defined parameters is not equal to the number of cell definitions in the parameter panel

In D365FO - SSRS report

Workaround solution:

1. Create new design (Shouldn't duplicate it from existing design)

2. Copy all objects from Old design and paste it in new design

3. Save report

4. Rebuild and deploy reports

Thursday, September 2, 2021

The data source is not embedded within a (parent) data source. (PU43 10.0.19 error) in D365FO

 The data source is not embedded within a (parent) data source. 


Write COC for FORM DS extension method

(In my case, SalesTable (Form) & SalesLine_IN (DS)). Even IN region localization not enabled.

Note: This has been fixed by MS as part of PU43 (10.0.19) + QU

1. Code fix solution (Temporary)

// Temporary fix for "The data source is not embedded within a (parent) data source." Error while opening All Sales order form after upgrade PU43 (10.0.19)

void init()

{

next init();

this.insertIfEmpty(false);

this.allowCreate(false);

}

2. Workaround solution (Temporary)

   //Changed personalize view to Standard view

Monday, July 12, 2021

Get Category Hierarchy levels X++ D365FO

 class GetCategoryLevels

{

    public static void main(Args _args)

    {

// TOP to BOTTOM hierarchy level data

        void loopchild(RefRecId     _recId)

        {

            EcoResCategory   ecoResCategoryChk, ecoResCategoryChild;

            while select ecoResCategoryChk

                where ecoResCategoryChk.ParentCategory ==  _recId

            {

                //Child query insert to table Write ur logic

                Info(ecoResCategoryChk.Name);

                ecoResCategoryChild.clear();

                select firstonly  ecoResCategoryChild

                    where ecoResCategoryChild.ParentCategory ==  ecoResCategoryChk.RecId;

                if(ecoResCategoryChild)

                {

                    loopchild(ecoResCategoryChild.ParentCategory);

                }

            }

        }

        EcoResCategory  ecoResCategory;

        EcoResProductCategory   ecoResProductCategory, ecoResProductCategoryCHk;

        RefRecId parentCategory;

        select firstonly  ecoResCategory

            where ecoResCategory.Name == "Refrigeration";

        parentCategory = EcoResCategory.RecId;

        if(parentCategory)

        {

            //Parent query insert  - Write ur logic

            Info(ecoResCategory.Name);

            loopchild(parentCategory);

        }

    }

}

Wednesday, June 16, 2021

Set range for SrsReportRunController through X++ D365FO

 Map queryContracts  = reportController.parmReportContract().parmQueryContracts();

        MapEnumerator mapEnumerator = queryContracts.getEnumerator();

        while(mapEnumerator.moveNext())

        {

            Query query = mapEnumerator.currentValue();

            if(query)

            {

                QueryBuildDataSource qbds = query.dataSourceTable(tableNum(WHSWorkLine)); 

                if(qbds)

                {

                    qbds.addRange(fieldNum(WHSWorkLine, ShipmentId)).value(queryValue(_shipmentTable.ShipmentId));

                }

            }

        }

Function to check whether DS is exists or not in QUERY D365FO

QueryBuildDataSource findFirstDsForTable(Query _q, TableId _tableId)

{

    QueryBuildDataSource ds;

    int i;

    for (i = 1; i <= _q.dataSourceCount(); i++)

    {

        ds = _q.dataSourceNo(i);

        if (ds.table() == _tableId)

        {

            return ds;

        }

    }

    return null;

}


Wednesday, May 12, 2021

Thursday, April 29, 2021

Dynamically FORM CONTROLS - Generate FormDataSource fields on FORM based on setup and sequence in D365FO

Form Method:

Init -> method

    public void init()

    {

 

        DictTable                   dictTable;

        FormBuildDataSource         fds;

        FormBuildDesign             formBuildDesign;

 

        #DEFINE.FormWidth(500)

        #DEFINE.FormHeight(300)

 

        this.dictTable = new DictTable(tableNum(<TableName>));

 

        this.fds = this.form().dataSource(formDataSourceStr(<FormName>,<TableName>));

 

        formBuildDesign = this.form().design();

        formBuildDesign.widthMode(-1);

        formBuildDesign.widthValue(#FormWidth);

        formBuildDesign.heightMode(-1);

        formBuildDesign.heightValue(#FormHeight);

 

 FormBuildGroupControl  tabGroupCtrl = formBuildDesign.control(‘GroupName’);

        tabGroupCtrl.dataSource(fds.id());

        tabGroupCtrl.allowEdit(true);

        tabGroupCtrl.hideIfEmpty(false);

 

        //We can loop it as well, if requires for all fields

        this.addField(dictTable.id(), fieldName2Id(dictTable.id(), configFields.FieldName), fds, tabGroupCtrl, true);

 

        super(); //All build control should generate before init super call

    }

Addfield -> method

protected void addField(tableId _tableId,

        fieldId _fieldId,

        FormBuildDataSource _formBuildDataSource,

        FormBuildGroupControl _formBuildGroupControl,

        boolean _allowControlEdit)

    {

        FormBuildStringControl formBuildStringControl;

        FormBuildInt64Control formBuildInt64Control;

        FormBuildIntControl formBuildIntControl;

        FormBuildComboBoxControl formBuildComboBoxControl;

        FormBuildCheckBoxControl formBuildCheckBoxControl;

        FormBuildTimeControl formBuildTimeControl;

        FormBuildDateControl formBuildDateControl;

        FormBuildGuidControl formBuildGuidControl;

        FormBuildDateTimeControl formBuildDateTimeControl;

        FormBuildRealControl formBuildRealControl;

        FormBuildSegmentedEntryControl formBuildSegmentedEntryControl;

        FormBuildReferenceGroupControl formBuildReferenceGroupControl;

 

        FormBuildControl formBuildControl;

       

        SysDictField dictField;

        int j;

        tableId rootTableId;

        str controlName;

        UtilElementName utilElmName;

        Types baseType;

 

        dictField = new SysDictField(_tableId, _fieldId);

        if(dictField.isSystem())

        {

            //System fields are only stored on the root table, so get the information from there.

            rootTableId = SysDictTable::getRootTable(_tableId);

            dictField = new SysDictField(rootTableId, _fieldId);

        }

 

        if (dictField.saveContents())

        {

            for(j = 1;j <= dictField.arraySize(); j++)

            {

                formBuildControl = null;

 

                controlName = strfmt('%1_%2', dictField.name(), j);

                baseType = dictField.baseType();

                utilElmName = dictField.typeName();

 

                switch (baseType)

                {

                    case Types::String:

                    case Types::RString:

                    case Types::VarString:

                        formBuildStringControl = _formBuildGroupControl.addDataField(_formBuildDataSource.id(), _fieldId, j);

                        formBuildStringControl.autoDeclaration(true);

                        formBuildStringControl.label(dictField.name());

 

                        formBuildStringControl.displayHeightMode(0);

                        formBuildStringControl.displayHeightValue(1);

 

                        formBuildControl = formBuildStringControl;

                        break;

 

                    case Types::Integer:

 

                        if (Global::isTypeTime(utilElmName))

                        {

                            formBuildTimeControl = _formBuildGroupControl.addDataField(_formBuildDataSource.id(), _fieldId, j);

                            formBuildTimeControl.autoDeclaration(true);

                            formBuildTimeControl.label(dictField.name());

 

                            formBuildControl = formBuildTimeControl;

                        }

                        else

                        {

                            formBuildIntControl = _formBuildGroupControl.addDataField(_formBuildDataSource.id(), _fieldId, j);

                            formBuildIntControl.autoDeclaration(true);

                            formBuildIntControl.label(dictField.name());

 

                            formBuildControl = formBuildIntControl;

                        }

                        break;

 

                    case Types::Int64:

                        // Reference Controls are created by default for surrogate foreign keys. However, the raw 64-bit

                        // integer should always be displayed. Force all Int64 type fields to use an Int64 Control.

                        formBuildControl = _formBuildGroupControl.addDataField(_formBuildDataSource.id(), _fieldId, j);

 

                        formBuildInt64Control = formBuildControl as formBuildInt64Control;

                        if (formBuildInt64Control != null)

                        {

                            formBuildInt64Control.autoDeclaration(true);

                            formBuildInt64Control.label(dictField.name());

                           

                            formBuildControl = formBuildInt64Control;

                        }

                        else

                        {

                            formBuildReferenceGroupControl = formbuildControl as FormBuildReferenceGroupControl;

                            if (formBuildReferenceGroupControl != null)

                            {

                                formBuildReferenceGroupControl.autoDeclaration(true);

                                formBuildReferenceGroupControl.label(dictField.name());

 

                                formBuildControl = formBuildReferenceGroupControl;

                            }

                            else

                            {

                                formBuildSegmentedEntryControl = formBuildControl as formBuildSegmentedEntryControl;

                                if (formBuildSegmentedEntryControl != null)

                                {

                                    formBuildSegmentedEntryControl.autoDeclaration(true);

                                    formBuildSegmentedEntryControl.label(dictField.name());

 

                                    formBuildControl = formBuildSegmentedEntryControl;

                                }

                            }

                        }

 

                        break;

 

                    case Types::Enum:

                        formBuildControl = _formBuildGroupControl.addDataField(_formBuildDataSource.id(), _fieldId, j);

 

                        formBuildComboBoxControl = formBuildControl as formBuildComboBoxControl;

                        if (formBuildComboBoxControl != null)

                        {

                            formBuildComboBoxControl.autoDeclaration(true);

                            formBuildComboBoxControl.label(dictField.name());

 

                            formBuildControl = formBuildComboBoxControl;

                        }

                        else

                        {

                            formBuildCheckBoxControl = formBuildControl as FormBuildCheckBoxControl;

                            if (formBuildCheckBoxControl != null)

                            {

                                formBuildCheckBoxControl.autoDeclaration(true);

                                formBuildCheckBoxControl.label(dictField.name());

 

                                formBuildControl = formBuildCheckBoxControl;

                            }

                        }

 

                        break;

 

                    case Types::Real:

                        formBuildRealControl = _formBuildGroupControl.addDataField(_formBuildDataSource.id(), _fieldId, j);

                        formBuildRealControl.autoDeclaration(true);

                        formBuildRealControl.label(dictField.name());

                       

                        formBuildControl = formBuildComboBoxControl;

 

                        break;

 

                    case Types::Guid:

                        formBuildGuidControl = _formBuildGroupControl.addDataField(_formBuildDataSource.id(), _fieldId, j);

                        formBuildGuidControl.autoDeclaration(true);

                        formBuildGuidControl.label(dictField.name());

 

                        formBuildControl = formBuildGuidControl;

 

                        break;

 

                    case Types::Date:

                        formBuildDateControl = _formBuildGroupControl.addDataField(_formBuildDataSource.id(), _fieldId, j);

                        formBuildDateControl.autoDeclaration(true);

                        formBuildDateControl.label(dictField.name());

                      

                        formBuildControl = formBuildDateControl;

                       

                        break;

 

                    case Types::UtcDateTime:

                        formBuildDateTimeControl = _formBuildGroupControl.addDataField(_formBuildDataSource.id(), _fieldId, j);

                        formBuildDateTimeControl.autoDeclaration(true);

                        formBuildDateTimeControl.label(dictField.name());

 

                        formBuildControl = formBuildDateTimeControl;

 

                        break;

                }

 

 

                if (formbuildControl != null)

                {

                    formbuildControl.name(controlName);

                    formbuildControl.helpText(dictField.label());

 

                    formBuildSegmentedEntryControl = formBuildControl as FormBuildSegmentedEntryControl;

                    if (formBuildSegmentedEntryControl != null)

                    {

                        // Segmented Entry controls should never be editable in the Table Browser.

                        // There is no way to specify a Controller class so the user would see errors.

                        formBuildSegmentedEntryControl.allowEdit(false);

                    }

                    else

                    {

                        formbuildControl.allowEdit(_allowControlEdit);

                    }

                }

            }

        }

    }


Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...