Unified Operations & Dynamics AX Forum

Expand all | Collapse all

ProdRoute not saving on RouteInventProd table extension

  • 1.  ProdRoute not saving on RouteInventProd table extension

    Posted Mar 08, 2019 08:12 AM
    We have added fields to ProdRoute table and RouteOpr table. The fields on both table extensions have been added to the Route field groups so they show on the UI forms. The issue is when trying to save the new fields from the RouteInventProd form where the new fields display, no data is saved to the ProdRoute table. Looks like we need to do some type of mapping of the new fields. We are trying to mimic the PropertyId field that is on both the ProdRoute and RouteOpr table.

    But again when we try and save from RouteInventProd form (found under Released products > ENGINEER > VIEW > Route) the values do not get saved. But the PropertyId field on the same Route group saves and that is what we are looking for.

    Any help would be appreciated.

    ------------------------------
    Jason Liveston
    ------------------------------


  • 2.  RE: ProdRoute not saving on RouteInventProd table extension

    TOP CONTRIBUTOR
    Posted Mar 08, 2019 10:35 AM
    It sounds like you are expecting to make a change on RouteInventProd form, and have it reflected on ProdRoute immediately? The form you are accessing, RouteInventProd stores data to Route, RouteOpr and RouteVersion tables.  It appears the form data source labels RouteOpr.PropertyId as ProdRoute.PropertyID, which is confusing.

    The actual table ProdRoute stores Routes that are tied to Production Orders, the ProdRoute data will not get initialized until you create a production order for that BOM / Formula item. So I would expect if you made the update to RouteInventProd, your new field gets update in RouteOpr, then when you create a new production order, ProdRoute will have your new field initialized if you updated the initialization method.

    My questions would be:
    1.) Do your extension fields show up when you access ProdRoute from the Production order -> Production Order Tab -> Production Details -> Route?

    2.) Does opening the master route from Production Control -> Operations -> All Routes -> Find your route -> Maintain -> Route Details and doing updates there give you any different experience?

    Maybe not the answer, but it might nudge you in the right direction.

    ------------------------------
    Colby Gallagher
    Manufacturing Systems Consultant
    Agility Business Solutions
    Brecksville OH
    ------------------------------



  • 3.  RE: ProdRoute not saving on RouteInventProd table extension

    Posted Mar 11, 2019 11:49 AM
    Hi Colby,

    Answer to your questions:

    1.) Do your extension fields show up when you access ProdRoute from the Production order -> Production Order Tab -> Production Details -> Route?

    My extension fields show up on ProdRoute but the data doesn't. The fields were added to both RouteOpr and ProdRoute and the fields were added to the Route group so they show on the UI automatically. But like I said if I make the change to the route information on the RouteInventProd  form from under released products the new fields to do save and do not save to RouteOpr or ProdRoute. If I open up "All Routes" and look the route up the new fields show existing data that was originally saved on that route but does not reflect the new updated values. The PropertyId field is updated to what I changed and is what I'm looking to duplicate.

    2.) Does opening the master route from Production Control -> Operations -> All Routes -> Find your route -> Maintain -> Route Details and doing updates there give you any different experience?

    I can updated the route values and save but like I mentioned above if I save from the released products > RouteInventProd from nothing from my new fields saves.

    N

    ------------------------------
    Jason Liveston
    ------------------------------



  • 4.  RE: ProdRoute not saving on RouteInventProd table extension

    GOLD CONTRIBUTOR
    Posted Mar 08, 2019 12:32 PM
    Here at Dynamics Resources we specialize in Dynamics 365, all versions of AX, and CRM. I ran your question by one of my experts.

    Please do a search for the [PropertyId] value in both the methods of the RouteInventProd form from the AOT, and in the related tables [DataSource] of that form.
    It is important to mention that there may be some method in the DataSource of the form that is modifying the insertion logic.
    You can also review the insert (), update () methods in the related tables to see if there is anything that is affecting it.
     
    You can verify if in some other place by means of the code the information of the field [PropertyId] is being inserted and try to adapt the same logic for your new field.


    ------------------------------
    Michael Gonzalez
    Account Executive
    Dynamics Resources
    Venon Hills IL
    ------------------------------



  • 5.  RE: ProdRoute not saving on RouteInventProd table extension

    Posted Mar 11, 2019 12:56 PM
    See my attachment, shows the PropertyId information and how it is coming from ProdRoute data source from the RouteInventProd form.

     public void write()
            {
                boolean insertMode = prodRoute.RecId ? false : true;
    
                try
                {
                    ttsbegin;
    
                    super();
    
                    routeInventForm.prodRouteDSWritePost(insertMode,forceTableRoute);
    
                    ttscommit;
    
                    if (insertMode)
                    {
                        wrkCtrRouteOprActivity_ds.executeQuery();
                    }
                    if (routeInventForm.mustRefreshAfterWrite())
                    {
                        this.refreshKeepPosition();
                    }
                }
                catch (Exception::Error)
                {
                    forceTableRoute = false;
    
                    throw Exception::Error;
                }
            }


    Looks like:   routeInventForm.prodRouteDSWritePost(insertMode,forceTableRoute);

    calls

      /// <summary>
        ///    Handles the transformation from a temporary <c>ProdRoute</c> buffer to a <c>RouteOpr</c> buffer.
        /// </summary>
        /// <param name="_insertMode">
        ///    true if it is the first time that the buffer is written; otherwise, false.
        /// </param>
        /// <param name="_forceTableRoute">
        ///    true if a new <c>RouteOpr</c> record must always be created; otherwise, false.
        /// </param>
        void prodRouteDSWritePost(
            boolean                     _insertMode,
            boolean                     _forceTableRoute = false
            )
        {
            recId                           recIdRoute;
            recId                           recIdRouteOpr;
    
            Route                           routeCmp;
            Route                           route;
    
            ProdRoute                       prodRouteCmp1;
            ProdRoute                       prodRouteCmp2;
    
            RouteOpr                        routeOprCmp;
            RouteOpr                        routeOpr;
            RouteOpr                        routeOprOrig;
    
            if (dropWrite)
            {
                dropWrite = false;
                return;
            }
    
            if (_insertMode || ! mapTmp2Route.exists(prodRoute.RecId))
            {
                route.RouteMap::initFromRouteMap(prodRoute);
                route.RouteId   = routeId;
                route.insert();
    
                this.insertMapRoute(prodRoute,route);
            }
            else
            {
                recIdRoute = mapTmp2Route.lookup(prodRoute.RecId);
    
                if (! mapRoute.exists(recIdRoute))
                    throw error(strfmt("@SYS19378",funcname()));
    
                route      = mapRoute.lookup(recIdRoute);
    
                prodRouteCmp1.RouteMap::initFromRouteMap(route);
                routeCmp.RouteMap::initFromRouteMap(prodRoute);
                prodRouteCmp2.RouteMap::initFromRouteMap(routeCmp);
    
                if (! bufCmp(prodRouteCmp1,prodRouteCmp2))
                {
                    route = Route::findRecId(recIdRoute,true);
                    if (! route.RecId)
                        throw error("@SYS5149");
    
                    route.RouteMap::initFromRouteMap(prodRoute);
                    route.update();
    
                    this.insertMapRoute(prodRoute,route);
                }
            }
    
            if (! mapTmp2RouteOpr.exists(prodRoute.RecId))
                _insertMode = true;
    
            if (_insertMode)
            {
                routeOpr = route.routeOpr(itemId,configId,siteId,routeOpr);
                if (routeOpr.RecId)
                {
                    this.removeMapRouteOpr(routeOpr);
                    this.insertMapRouteOpr(prodRoute,routeOpr);
    
                    _insertMode = false;
                }
                else
                {
                    routeOpr.ItemCode       = TableGroupAll::Table;
                    routeOpr.ItemRelation   = itemId;
                    routeOpr.ConfigId       = configId;
                    routeOpr.RouteCode      = RouteAll::Route;
                    routeOpr.RouteRelation  = routeId;
    
                    routeOpr.RouteOprMap::initFromRouteOprMap(prodRoute);
                    routeOpr.SiteId         = siteId;
                    routeOpr.insert();
    
                    this.insertMapRouteOpr(prodRoute,routeOpr);
                }
            }
    
            if (! _insertMode)
            {
                recIdRouteOpr = mapTmp2RouteOpr.lookup(prodRoute.RecId);
    
                if (! mapRouteOpr.exists(recIdRouteOpr))
                    throw error(strfmt("@SYS19378",funcname()));
    
                routeOprOrig  = mapRouteOpr.lookup(recIdRouteOpr);
    
                prodRouteCmp1.clear();
                prodRouteCmp2.clear();
    
                prodRouteCmp1.RouteOprMap::initFromRouteOprMap(routeOprOrig);
                routeOprCmp.RouteOprMap::initFromRouteOprMap(prodRoute);
                prodRouteCmp2.RouteOprMap::initFromRouteOprMap(routeOprCmp);
    
                if (! bufCmp(prodRouteCmp1,prodRouteCmp2) || _forceTableRoute)
                {
                    this.removeMapRouteOpr(routeOprOrig);
    
                    select forupdate routeOpr
                        index hint OprRelIdx
                        where routeOpr.OprId          == prodRoute.OprId        &&
                              routeOpr.ItemCode       == TableGroupAll::Table   &&
                              routeOpr.ItemRelation   == itemId                 &&
                              routeOpr.ConfigId       == configId               &&
                              routeOpr.RouteCode      == RouteAll::Route        &&
                              routeOpr.RouteRelation  == routeId                &&
                              routeOpr.SiteId         == siteId;
    
                    if (routeOpr.RecId)
                    {
                        this.removeMapRouteOpr(routeOpr);
    
                        routeOpr.RouteOprMap::initFromRouteOprMap(prodRoute);
                        routeOpr.update();
                    }
                    else
                    {
                        routeOpr.clear();
                        routeOpr.ItemCode       = TableGroupAll::Table;
                        routeOpr.ItemRelation   = itemId;
                        routeOpr.ConfigId       = configId;
                        routeOpr.RouteCode      = RouteAll::Route;
                        routeOpr.RouteRelation  = routeId;
    
                        routeOpr.RouteOprMap::initFromRouteOprMap(prodRoute);
                        routeOpr.SiteId         = siteId;
                        routeOpr.insert();
    
                        Docu::copy(routeOprOrig,routeOpr);
    
                        //Copy requirement set and requirements
                        WrkCtrActivityRequirementSet::copyRequirements(routeOprOrig.activity(),routeOpr.activity());
                    }
    
                    this.insertMapRouteOpr(prodRoute,routeOpr);
                }
            }
        }


    But again, no PropertyId showing. I did see where there is a mappings under ProdRoute table, Mappings: RouteOprMap, see the attachment. Since you can't extend a map, I created a new one and added it to both ProdRoute and RouteOpr just as they do and still no luck.



    ------------------------------
    Jason Liveston
    ------------------------------



If you've found this thread useful, dive deeper into User Group community content by role