Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

AX2012 Form Code Upgrade error

Posted on by 2,695

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();

Categories:
  • lispyj Profile Picture
    lispyj 2,695 on at
    RE: AX2012 Form Code Upgrade error

    That worked.  Thanks!

  • Verified answer
    Jonathan  Halland Profile Picture
    Jonathan Halland 11,302 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
    lispyj 2,695 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
    lispyj 2,695 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
    Jonathan Halland 11,302 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?

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,995 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,610 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans