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

AX2012 Form Code Upgrade error

(0) ShareShare
ReportReport
Posted on by 201

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

I have the same question (0)
  • Jonathan  Halland Profile Picture
    11,310 on at

    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?

  • lispyj Profile Picture
    201 on at

    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.

  • lispyj Profile Picture
    201 on at

    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.

  • Verified answer
    Jonathan  Halland Profile Picture
    11,310 on at

    Hi Lispyj

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

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

  • lispyj Profile Picture
    201 on at

    That worked.  Thanks!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans