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)

Docuref , change TypeId

(0) ShareShare
ReportReport
Posted on by 1,435

Hello all,

At our company we have all product drawings attached to a product. The most recent drawings have a TypeId "Recent". 

When something changes, a new drawing is attached. This new drawing again gets typeId "Recent". The problem is that a user then has to delete all the old drawings, and attach them again with TypeId "Old". 
This because you cannot change the TypeId anymore once an attachment has been made.

Now I can update the TypeId manually quickly trough X++ (just select the docuref document, and update the typeId). This works fine in our test environment:


[quote]
while select forUpdate docuref where docuref.refrecid==5637164103

{
if(DocuRef.TypeId=="Recent")
{
   docuref.typeId="Old";

   ttsBegin;
      docuref.update();
   ttscommit;
}

[/quote]


My question is: is this safe? Can I just update it in the table? I would say yes, but I cannot understand why it is not possible to change it through the user interface if it would be that simple

Thanks in advance.

Kind regards, Willem.

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Hi Willem,

    instead of updating at table level, why can't you write code to change the type id of previous records before inserting new record.

    Find all the records in docuref table with docuref.ReftableId= tablenum(your table) and docuref.RefRecid = product.recid and set docuref.TypeId = "old" call this method before insert method.

  • Verified answer
    Jesus R. ABASCAL Profile Picture
    1,450 on at

    Users can't set to "OLD" typeId due to table field properties. TypeIs allows edit on create but not then.

    3365.Capture.PNG

    I suggest you, create a button that runs a small action (Class) that update the typeId of select record.

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

    Hi Willem.

    This seems like a misuse of the TypeId field. The type of a document should not logically change once you have created it. i.e. The file has not changed, so its impossible for its "type" to have changed. Perhaps you should rather have an alternate field on your table called "Latest" where a user can select which one is the latest document.

  • Wvduren Profile Picture
    1,435 on at

    Thank you all for your replies.

    Raghuk35: what would be the advantage compared to the updating on table level?

    Jesús: Yes that's what I will do. Thank you. I will update it on table level using a small class.

    Jonathan: Yes I agree: It is a misuse with the goal to stay as close to the 'basic ax tables' as possible.

    Thanks again!

    Kind regards, Willem.

  • Jonathan  Halland Profile Picture
    11,310 on at

    Hi Willem.

    I hope Jesus' solution will work for you. Just becareful that in your attempt to stay close to standard AX in table structure you are deviating in business logic which may have more serious repercussions than simply adding a new field. There is a reason they have disabled one from changing the type after creation.

    An alternate could also be to have a display method on your table that simply displays "Recent" for the document with the latest createdDateTime field. That way you would not be changing the table or changing business logic.

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 Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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 21

#2
Harisgillani Profile Picture

Harisgillani 4

#2
dekion Profile Picture

dekion 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans