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)

Fetching extra fields from TFS to check-in dialog

(0) ShareShare
ReportReport
Posted on by

Good morning, I am working in the integration of ax 2012 R3 and TFS 2018. actually it works, my problem is how to custumize the Check in form in order to add some Tfs fields such as "AssignedTo" fields.  I could add the field in the form" SysVersionControlCheckIn"  and in the table, but i could not retreive information ( I mean the value of the field assigned To refering to the WorkItem) from TFS.  After searching the place where they populate values i found the class SysVersionControlWorkItemProviderTFS, exactly in the methode insertWorkItemToTable, but i didn't find how they populate values from tfs.  Can you help me please.  Thank you so much

Cliquez ou appuyez sur Entrée pour afficher sysVersioncontrolCheckIn.PNG dans l’aperçu de photosysVersioncontrolCheckIn.PNG

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    239,069 Most Valuable Professional on at

    And by the way, don't forget to recompile the code using the macro (not just where the macro is defined).

  • Martin Dráb Profile Picture
    239,069 Most Valuable Professional on at

    SysVersionControlWorkItemProviderTFS class should contain a work item query in a macro. Do you see it? That's the first place you must change - you'll change the query to return an extra field.

    Then you'll have to put the value (returned from a .NET library) to the table; unfortunately I don't remember the implementation and I don't have any AX 2012 environment on hand. If you think it's in insertWorkItemToTable() but you don't understands the code, please share it with us.

  • Community Member Profile Picture
    on at

    Thank you for your response,

    1/   i have modified the query in order to return the field "Assigned To" as shown below :

    /// <summary>

    /// The <c>SysVersionControlWorkItemProviderTFS</c> class allows for TFS work items to be associated

    /// with a Version Control System (VCS) check-in.

    /// </summary>

    // This is a framework class. Customizing this class may cause problems with future upgrades to the software.

    public class SysVersionControlWorkItemProviderTFS implements SysVersionControlWorkItemProvider

    {

       Microsoft.Dynamics.AX.Framework.TeamFoundationServerFacade.WorkItemStoreProxy workItemStoreProxy;

       Microsoft.Dynamics.AX.Framework.TeamFoundationServerFacade.WorkItemProxyCollection workItemsCache;

       #define.AssignedToMeQuery("SELECT [System.Id], [System.Title], [System.State], [System.WorkItemType], [System.AssignedTo] FROM WorkItems WHERE [System.TeamProject] = @project  AND  [System.AssignedTo] = @me ORDER BY [System.Id]")

    }

    2/ My problem is how to get CurrentUser from WorkItem!!!!!, for example when i affect a string("CurrentUser") to Target.AssignedTo it appears in the form.

    Question: WorkItem has methods to get title, id, i want to know if there is a way to add another methode get_assignedTo ??

    code bellow :

    private void insertWorkItemToTable(

       SysVersionControlTmpWorkItems target,

       Microsoft.Dynamics.AX.Framework.TeamFoundationServerFacade.WorkItemProxy workItem)

    {

       int id;

       str title;

       System.Type clrWorkItemType;

       int instanceFlag = CLRInterop::getAnyTypeForObject(System.Reflection.BindingFlags::Instance);

       int publicFlag = CLRInterop::getAnyTypeForObject(System.Reflection.BindingFlags::Public);

       int combinedFlag = instanceFlag | publicFlag;

       System.Reflection.BindingFlags propertyReflectFlags;

       System.Reflection.PropertyInfo propInfo;

       anytype propertyValue;

       CLRObject clrPropertyValue;

       System.Object nullIndex;

       id = workItem.get_Id();

       title = workItem.get_Title();

       target.AssignedTo = "CurrentUser"; // the current user should be retreived from workItem

       target.ID = id;

       target.Title = title;

       clrWorkItemType = workItem.GetType();

       if (clrWorkItemType != null)

       {

           propertyReflectFlags = System.Reflection.BindingFlags::Default;

           propertyReflectFlags = System.Enum::ToObject(propertyReflectFlags.GetType(), combinedFlag);

           // BP Deviation Documented

           nullIndex = new System.Object[0]();

           propInfo = clrWorkItemType.GetProperty('State', propertyReflectFlags);

           if (propInfo != null && propInfo.get_CanRead())

           {

               clrPropertyValue = propInfo.GetValue(workItem, nullIndex);

               PropertyValue = CLRInterop::getAnyTypeForObject(clrPropertyValue);

               target.State = any2str(propertyValue);

           }

           propInfo = clrWorkItemType.GetProperty('WorkItemType', propertyReflectFlags);

           if (propInfo != null && propInfo.get_CanRead())

           {

               clrPropertyValue = propInfo.GetValue(workItem, nullIndex);

               PropertyValue = CLRInterop::getAnyTypeForObject(clrPropertyValue);

               target.Type = any2str(propertyValue);

           }

       }

       target.insert();

       if (workItemsCache.GetById(id) == null)

       {

           workItemsCache.Add(workItem);

       }

    }

  • Martin Dráb Profile Picture
    239,069 Most Valuable Professional on at

    What's the point of fetching AssignTo field if you have a condition to return only work items assigned to the current user ([System.AssignedTo] = @me)?

    If you want to know whether WorkItemProxy class has get_AssignedTo() method, why don't you take a look? I can't do it for you (because I don't have AX 2012 environment).

    If it doesn't have such a method, try the approach with reflection, which is used above for getting State and WorkItemType.

    By the way, please use the </> button in the rich formatting view to paste source code; it makes it easier to read.

  • Community Member Profile Picture
    on at

    Hello, thanks for your response,

    1 - I want to fetch AssignedTo field in order to see tasks that are not assigned to me, so i have cleaned the condition  ([System.AssignedTo] = @me)

    2 -there is no class WorkItemProxy  in order to check the possibility to add methods i think it's in system layer

    3- I have tried the approach with reflection:

    3.1 when i execute this code :

    </  propInfo= clrWorkItemType.GetProperty('AssignedTo');

            if ( propInfo != null && propInfo.get_CanRead())

           {

            clrPropertyValue = propInfo.GetValue(workItem,nullindex);// get value

            PropertyValue = CLRInterop::getAnyTypeForObject(clrPropertyValue);

           target.AssignedTo = any2str(propertyValue);

           }>

    nothing happens

    the value of the field Assigned is not retreived and no error is thrown

    3.2 i tried to know if propInfo is empty so i changed the condition

    </ propInfo= clrWorkItemType.GetProperty('AssignedTo');

            if ( propInfo == null && propInfo.get_CanRead())

           {

            clrPropertyValue = propInfo.GetValue(workItem,nullindex);// get value

            PropertyValue = CLRInterop::getAnyTypeForObject(clrPropertyValue);

           target.AssignedTo = any2str(propertyValue);

           }>

    i had this error :

    </SysVersionControlWorkItemProviderTFS objet not initialized.>

    thank you so much.

  • Martin Dráb Profile Picture
    239,069 Most Valuable Professional on at

    WorkItemProxy isn't a system class, it's a .NET class. You should be able to simply use IntelliSense to see its public methods and properties, or open the assembly in object browser in Visual Studio or even decompile the code. But the best approach may be running the code in CIL and examining workItem object in Visual Studio debugger.

    Nevertheless it seems that you successfully get AssignedTo property via reflection, right? The comment in your code suggests that the problem lies in GetValue().

    The second piece of code is guaranteed to throw an error, because you try to call a method on a null object.

    Regarding code pasting, this is how it should look like when you use the </> button in the rich formatting view:

    propInfo = clrWorkItemType.GetProperty('AssignedTo');
    if (propInfo != null && propInfo.get_CanRead())
    { 
        clrPropertyValue = propInfo.GetValue(workItem,nullindex);// get value
        PropertyValue = CLRInterop::getAnyTypeForObject(clrPropertyValue);
        target.AssignedTo = any2str(propertyValue);
    }

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 March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
Basit Profile Picture

Basit 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans