Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Unanswered

Error "Wrong type of argument for conversion function" occured with array field

Posted on by 10
Hi experts,
 
I want to use array field (extends from HcmWorkerRecId), but error is found when form datasource appending new record.
 
The followings are the steps:
1. Create a EDT A (Extends = HcmWorkerRecId, Reference Table = HcmWorker, new table refereneces and 4 array elements are added)
2. Drag this EDT to table
3. Table is set as form datasource, and drag related field to grid, 4 reference group controls are added.
 
While new record is appended, error is found when code Class\FormDataUtil\getRefRecIdFieldValue executing.
 
Can anyone tell me how to resolve this problem?
Thanks in advance.
 
Bernard
  • YQ-12070237-0 Profile Picture
    YQ-12070237-0 10 on at
    Error "Wrong type of argument for conversion function" occured with array field
    Hi Andre, Anton
     
    I have implement it with several fields instead of using array field.
     
    Thanks both of you anyway.
     
    Bernard
     
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 290,537 Super User 2024 Season 2 on at
    Error "Wrong type of argument for conversion function" occured with array field
    Hi Bernard,
     
    Anton explained that the field IDs of array fields are implemented differently. I guess the reference fields with array-type fields are not supported in the standard coding. If the 4 distinct fields are working, I guess this should be your solution.
  • Anton Venter Profile Picture
    Anton Venter 18,531 Super User 2024 Season 2 on at
    Error "Wrong type of argument for conversion function" occured with array field
    Hello,
     
    The field IDs of the array fields work a little different. You have to use the extended field ID methods, see link below.
     
  • YQ-12070237-0 Profile Picture
    YQ-12070237-0 10 on at
    Error "Wrong type of argument for conversion function" occured with array field
    Hi Andre,
     
    The parameter _fieldId is 1, and it is the array field number. If I remove it, and add 4 fields instead, it woks fine.
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 290,537 Super User 2024 Season 2 on at
    Error "Wrong type of argument for conversion function" occured with array field
    Hi Bernard,

    Apologies, I misread your question and thought you shared custom coding. If you are using the debugger, doe the parameter _fieldId have a value? 
    Do you get the same error in case you are not using the arrays on this field, but one or e.g. 4 distinct fields?
  • YQ-12070237-0 Profile Picture
    YQ-12070237-0 10 on at
    Error "Wrong type of argument for conversion function" occured with array field
    Thank you Andre for your reply. However, the method getRefIdFieldValue is the code of module plateform. I know I can extend it in my module, but does it mean that this is a bug for basic code?
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 290,537 Super User 2024 Season 2 on at
    Error "Wrong type of argument for conversion function" occured with array field
    Hi,
     
    When you are using the Common object, the outcome of the field value is an anytype instead of an integer64.  You can change your coding in the following way to have the proper conversion:
     
    RefRecId refId = any2Int64(_record.(_fieldId));
     

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,537 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans