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 :
Microsoft Dynamics AX (Archived)

changecompany not changing the company please see the below code

(0) ShareShare
ReportReport
Posted on by

display CompanyName companyName()
{
CompanyName nameOfCompany;
axpContractTable contractCompany; // trying to check companycode field from this table
CompanyInfo company;

;
// contractCompany = axpContractTable::find(warehouseTable.ContractId);
//if (contractCompany.CompanyCode)
while select contractCompany
{
if (contractCompany.dataAreaId == '003')
{
changecompany(contractCompany.CompanyCode)

{
nameOfCompany = CompanyInfo::name();
}
}
if (contractCompany.dataAreaId == '014')
{
changecompany(contractCompany.CompanyCode)

{
nameOfCompany = CompanyInfo::name();
}
}
}

return nameOfCompany;
}

*This post is locked for comments

I have the same question (0)
  • krishna.rao@dax Profile Picture
    3,006 on at

    You won't get helped unless you explain in a better way.

    Where you are getting the problem in whole the script?

    No one make waste of time by guessing.

    Explain with an example in a better way so that someone could understand and reply.

  • Community Member Profile Picture
    on at

    when i am running a report i am trying to change the company name.

    From the axpcontractable  i am having different company codes. I am running the report from the default companies 003 & 014 then i am selecting axpcontracttable from there i am  trying  to get various companies codes.

  • krishna.rao@dax Profile Picture
    3,006 on at

    Initially test in a job to know whether you are getting the data or not.

    You need to reset the table buffer while using Changecompany() otherwise result will be too heavy as the buffer contains old data as well.

    while select contractCompany
    {
    nameOfCompany = null; // reset the table buffer 
    if (contractCompany.dataAreaId == '003')
    {
    changecompany(contractCompany.CompanyCode)
    {
    nameOfCompany = CompanyInfo::name();
    }
    }
    if (contractCompany.dataAreaId == '014')
    {
    changecompany(contractCompany.CompanyCode)
    {
    nameOfCompany = CompanyInfo::name();
    }
    }
    info(nameOfCompany.FieldName);// display the msg to test
    }

  • Suggested answer
    UmesH@ Profile Picture
    810 on at
    static void ChangeCompany(Args _args)
    {
    
    CompanyName nameOfCompany;
    TableName contractCompany; // trying to check companycode field from this table
    CompanyInfo company;
    ;
    // contractCompany = axpContractTable::find(warehouseTable.ContractId);
    //if (contractCompany.CompanyCode)
    //contractCompany.dataAreaId will be Different like-ceu,ceed,cee
    //contractCompany.LegalEntity aslo will be different like-ceu,ceed,cee
    //contractCompany.LegalEntity like-ceu,ceed,cee,this Legalentity Could be Multiple in table per contractCompany.dataAreaId.
    like while select contractCompany { if (contractCompany.dataAreaId == 'ceu') { changecompany(contractCompany.LegalEntity) { nameOfCompany = curext(); info(strFmt("Name : %1",nameOfCompany)); } } if (contractCompany.dataAreaId == 'ceed') { changecompany(contractCompany.LegalEntity) { nameOfCompany =curext(); info(strFmt("Name : %1",nameOfCompany)); } } if (contractCompany.dataAreaId == 'cee') { changecompany(contractCompany.LegalEntity) { nameOfCompany =curext(); info(strFmt("Name : %1",nameOfCompany)); } } } }

    Might be Help You.

  • Community Member Profile Picture
    on at

    hi

    jignesh patel

    thanks for you valuable effort i am getting the following error.

    whether i want to change company name field string to text.

    Capture_5F00_221215.JPG

  • Suggested answer
    UmesH@ Profile Picture
    810 on at

    Make this method Display have you done it.Thern return you company parameter.

    and return ur company parameter end of if condition inside while loop.

    This is JOB

    static void ChangeCompany(Args _args)
    {
    
    CompanyName nameOfCompany;
    TableName contractCompany; // trying to check companycode field from this table
    CompanyInfo company;
    ;
    // contractCompany = axpContractTable::find(warehouseTable.ContractId);
    //if (contractCompany.CompanyCode)
        while select contractCompany
        {
            if (contractCompany.dataAreaId == 'ceu')
            {
                changecompany(contractCompany.LegalEntity)
                {
                    nameOfCompany = curext();
                    //info(strFmt("Name : %1",nameOfCompany));
                }
            }
            if (contractCompany.dataAreaId == 'ceu')
            {
                changecompany(contractCompany.LegalEntity)
                {
                    nameOfCompany =curext();
                    //info(strFmt("Name : %1",nameOfCompany));
                }
            }
            if (contractCompany.dataAreaId == 'ceu')
            {
                changecompany(contractCompany.LegalEntity)
                {
                    nameOfCompany =curext();
    
                }
            }
            info(strFmt("Comapny-Name : %1",nameOfCompany));
        }
    }

    Sure you will get Company Name.

    Thanks.

  • ILDAR Profile Picture
    65 on at

    Hi,

    I think if you table on which display method resides is contractCompany you can just use

    public display CompanyName companyName()

    {

       return CompanyInfo::findDataArea(this.dataAreaId).Name;

    }

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans