Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

AX2012 Form Code Upgrade error

(0) ShareShare
ReportReport
Posted on by 110

I am upgrading the code for a custom form from AX2009 to AX2012 R3.  I receive the following error on the init method of the ShipCarrierTracking datasource.

"The assignment is invalid because the variable shipCarrierTracking is read only"

The line of code:

shipCarrierTracking = element.args().record();

Can anyone tell me what is up?

The entire method:

public void init()

{

Query query;

QueryBuildDataSource qbds;

;

if(element.args())

{

if(element.args().dataset() == tablenum(ShipCarrierTracking))

{

shipCarrierTracking = element.args().record();

query = new Query();

qbds = query.addDataSource(tablenum(ShipCarrierTracking));

qbds.addRange(fieldnum(ShipCarriertracking, PackingSlipId)).value(queryValue(shipCarrierTracking.PackingSlipId));

qbds.addRange(fieldnum(ShipCarrierTracking, SalesId)).value(queryValue(shipCarrierTracking.SalesId));

this.query(query);

}

}

super();

*This post is locked for comments

  • lispyj Profile Picture
    110 on at
    RE: AX2012 Form Code Upgrade error

    That worked.  Thanks!

  • Verified answer
    Jonathan  Halland Profile Picture
    11,306 on at
    RE: AX2012 Form Code Upgrade error

    Hi Lispyj

    Depending on what exactly you want to do you can use the following:

    shipCarrierTracking.data(element.args().record());

  • lispyj Profile Picture
    110 on at
    RE: AX2012 Form Code Upgrade error

    The form itself just displays a ShipCarrierTracking record so that it can be edited as needed.  The error occurs when attempting to set the datasource record to equal the record in the buffer.  I wondered if the issue is related to AX2012 for Edit Mode changes.

  • lispyj Profile Picture
    110 on at
    RE: AX2012 Form Code Upgrade error

    The code is in the init method of the ShipCarrierTracking datasource on the form. The datasource uses the ShipCarrierTracking table.  This code compiled and function correctly in AX2009.  To me is sounds like the ShipCarrierTracking table is somehow read only, but I don't know where that might be defined.

  • Jonathan  Halland Profile Picture
    11,306 on at
    RE: AX2012 Form Code Upgrade error

    Hi

    Without knowing a bit more behind the form, one may struggle to determine the issue. Where is ShipCarrierTracking variable declared in your 2012 form? Also Do you perhaps have a "ShipCarrierTracking" datasource on your new form?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,865 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans