最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

Extend the PurchRFQTable2Line Framework (AX 2012)

网络文摘 William 2348浏览 0评论

This is the my third post regarding the “Table 2 Line Update” mechanism in Dynamics AX.  This shows you how to extend the request for quotations framework to update changes made to the header to the lines. The other post can be found here:

Example: Add a preferred shipping carrier

Use the existing extended data type TMSCarrierCode to add a new field called PreferredCarrier to the

  • PurchRFQCaseTable,
  • PurchRFQCaseLine
  • and the map PurchRFQTableMap

At the PurchRFQTableMap, add the new field PreferredCarrier to the HeaderToLineUpdate field group. Define a mapping for the PurchRFQCaseTable PreferredCarrier field. At the AxPurchRFQCaseTable class add the following parm and set methods

image

At the AxPurchRFQCaseLine class add the following parm and set methods

protected void setPreferredCarrier()
{    
    if (this.isMethodExecuted(funcName(),  
        fieldNum(PurchRFQCaseLine,PreferredCarrier)))     
       {        
           return;  
       }

    this.setAxPurchRFQCaseTableFields();    
    if (this.isAxPurchRFQCaseTableFieldsSet() ||
        this.axPurchRFQCaseTable().isFieldModified(
        fieldNum(PurchRFQCaseTable, PreferredCarrier)))    
    {        
        this.parmPreferredCarrier(this.axPurchRFQCaseTable()
                                    .parmPreferredCarrier());    
    }
}

 

public Name parmPreferredCarrier(TMSCarrierCode _PreferredCarrier = “)
{     
    if(!prmisDefault(_PreferredCarrier))    
    { 
        this.setField(fieldNum(PurchRFQCaseLine, PreferredCarrier),
                                                 _PreferredCarrier);     
    }
    return purchRFQCaseLine.PreferredCarrier;
}

At the AxPurchRFQCaseLine.setTableFields() method add the call of the setPreferredCarrier method

 

protected void setTableFields()
{   
    // <GIN>  #ISOCountryRegionCodes
    useMapPolicy = false;
    // </GIN>    super();
    this.setLineNum();    this.setLineNumber();
    // … lot of set* calls here
    useMapPolicy = true;

    //ERP     
    this.setPreferredCarrier();
}

public FieldLabel lineUpdateDescription()

    switch(fieldExt2Id(this.fieldId()))     
    {       
        case fieldNum(PurchRFQTableMap, DefaultDimension):           
        return "@SYS14926";
        case fieldNum(PurchRFQTableMap, InventLocationId):           
        return "@SYS108782";
        case fieldNum(PurchRFQTableMap, DeliveryDate):            
        return fieldId2pname(tableNum(PurchRFQCaseLine),
                              fieldNum(PurchRFQCaseLine, DeliveryDate));
        case fieldNum(PurchRFQTableMap, ExpiryDateTime):           
        return fieldId2pname(tableNum(PurchRFQCaseLine),
                             fieldNum(PurchRFQCaseLine, ExpiryDateTime));
        case fieldNum(PurchRFQTableMap, TaxGroup):            
        return fieldId2pname(tableNum(PurchRFQLine),
                             fieldNum(PurchRFQLine, TaxGroup));
        case fieldNum(PurchRFQTableMap, LanguageId):            
        return fieldId2pname(tableNum(PurchRFQCaseLine),
                             fieldNum(PurchRFQCaseLine, Name));
        // ERP preferred carrier
        case fieldNum(PurchRFQTableMap, PreferredCarrier):           
        return fieldId2pname(tableNum(PurchRFQCaseLine),
                            
fieldNum(PurchRFQCaseLine,PreferredCarrier));
    }
    throw error(strFmt("@SYS19306",funcName()));
}

In the PurchRFQCaseTable2LineUpdate class, extend the getFieldIdFromMappedTable() method to support the new PreferredCarrier field

FieldId getFieldIdFromMappedTable(FieldId _mapFieldId)

    switch(_mapFieldId)    
    {       
        case fieldNum(PurchRFQTableMap, DefaultDimension) :
        return fieldNum(PurchRFQCaseTable, DefaultDimension);       
        case fieldNum(PurchRFQTableMap, InventLocationId) : 
        return fieldNum(PurchRFQCaseTable, InventLocationId);       
        case fieldNum(PurchRFQTableMap, InventSiteId)     :
        return fieldNum(PurchRFQCaseTable, InventSiteId);       
        case fieldNum(PurchRFQTableMap, DeliveryDate)     :
        return fieldNum(PurchRFQCaseTable, DeliveryDate);       
        case fieldNum(PurchRFQTableMap, ExpiryDateTime)   :
        return fieldNum(PurchRFQCaseTable, ExpiryDateTime);       
        case fieldNum(PurchRFQTableMap, LanguageId)       :
        return fieldNum(PurchRFQCaseTable, LanguageId);
        // ERP       
        case fieldNum(PurchRFQTableMap, PreferredCarrier) :  
        return fieldNum(PurchRFQCaseTable, PreferredCarrier); 
    }
    return 0;
}

Go to Procurment and Sourcing module > Setup > Procurement and Sourcing Parameters > Request for Quotation and open the Update request for quotation lines. You should see the parameter dialog including the new Carrier field. Set the Update method to Prompt.

image


发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址