web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

unable to get Document TypeId , in a button

(0) ShareShare
ReportReport
Posted on by 3,945

hi all ,

I have added one button namely "Upload" in the DocuView form whose datasource is DocuRef.
In the clicked method of the same button i have written this 

if(element.args().dataset() == tableNum(DocuRef))
{
callerDocuRef = element.args().record();
filetype = callerDocuRef.TypeId;
info(filetype);
}

but here in message i am nothing getting , it means my condition is not satisfying .
My requirement is that : - Whenever a user click upload after selecting any record from the same form (DocuView), then one message should display there, in message in need to display the file type which user has selected.

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    syed baber Profile Picture
    11,633 on at

    Hi Gautam,

    Use the following code:

    Common callerRecord;

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

    if (callerRecord.tableId == tablenum(DocuRef))

    {

      //Write your code here

    }

    Please let me know if you have further queries.

    Thanks,

    Baber.

  • Gautam Profile Picture
    3,945 on at

    hi Baber ,

    Have a look to this code its not working

    Common      callerRecord;

    DocuRef       callerDocuRef;

    str                filetype;

    super();

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

    if (callerRecord.tableId == tablenum(DocuRef))

    {

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

       filetype = callerDocuRef.TypeId;

       info(filetype);

    }

    Please tell what to do.

    Thanks

  • Jonathan  Halland Profile Picture
    11,310 on at

    Hi Gautam.

    Can you explain what you are trying to do regarding document handling as a whole? You have a whole load of forum posts that seem to be related to uploading files in document management when Document mangement does this anyway. Maybe there is just a few configuration changes that you actually need to make.

  • Gautam Profile Picture
    3,945 on at

    ya ..i will explain you

    In DocuView Form ,in Action Pane , a new button is there .

    When we click new , which all the type of document is present  , its displaying in drop down. Right

    Lets Say we selected "File" from drop down , when we select this a window will open to select the document/file from our machine. Right

    Two button are there "OK" and "Cancel ", when we click cancel then record will create in DocuRef table but that file name/ file path is not get saved because user has clicked "cancel " button.

    Due to this reason i am doing customization , suppose after clicking "cancel" button , user

    now want to select/upload the file/document for the same record which user has cancelled earlier, so to do this user need to delete the record first and then again new button -> file.

    That's why i have added "upload" button there so its easy for any user to again upload the file / document.

  • Jonathan  Halland Profile Picture
    11,310 on at

    OK, I think I understand. It seems strange that the docuref document is left after clicking cancel. I would rather look towards deleting this record rather than trying to fix it. However that said, where are you placing the above code? Also what is not working precisely about it?

  • syed baber Profile Picture
    11,633 on at

    Hi Gautam,

    Did you debug the code? What value is showing in TableID field? Please check and let me know.

    Thanks,

    Baber.

  • Gautam Profile Picture
    3,945 on at

    Hi Baber

    Debugger is jumping this if condition

    if (callerRecord.tableId == tablenum(DocuRef))

    Thanks

  • syed baber Profile Picture
    11,633 on at

    Hi Gautam,

    Check what is showing in tableId field. Or print callerRecord.tableID in infolog to see what value is coming in this field. Or check if callerRecord is populating correctly.

    Thanks,

    Baber.

  • Sohaib Cheema Profile Picture
    49,664 Super User 2026 Season 1 on at

    gautam,

    see an example here

    www.dynamics101.com/.../applying-document-management-framework-microsoft-dynamics-ax-2012

    otherwise you can customize DocuActionArchive(class) >> add (method)

    this is where the code is to save file. so possibly you can detect there by code that if no file selected and has been canceled, remove related reference record.

    moreover remember that this should be only for the case of file. as for the case of Notes or URL etc, there is no attachment physically

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

    Hi Gautam.

    Where is this code place? The element.args will not return DocuRef, but most likely your source document e.g. Purchase Requisition etc.

    Depending on where the code is you can simply use the ACTIVE docuRef datasource on your form (if this is on DocuView)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 34

#1
CP04-islander Profile Picture

CP04-islander 34

#3
Jagadabi Profile Picture

Jagadabi 6

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans