Wednesday, May 28, 2014

DMF – Stack Trace error @ \Tables\DMFEntity\generateXML_WPF


It appears that whenever you go to Company/Data import export framework/Setup/Target Entities and then click on an entity then “Modify target mapping” you may get a stack trace error that is linked to \Tables\DMFEntity\generateXML_WPF and it will not allow you to open up this window for the specific entity but it will for others. To fix the error you should first try the following:

 

1.       Open \Tables\DMFEntity\generateXML_WPF and the issue is between line 201-208.

a.      What happens is the SysDictField object is called but if the table no longer contains the field in the mapping then it generates a “null” instance of SysDictField which is called on line 204 which causes an error to be thrown.

2.       We need to modify the code base for DMF so it can handle null objects and let us know where the issue is

3.       The following from line 196-209 should be changed:

Orignal:

// Generate Target Fields

    while select Entity, XMLField, TargetTable, TargetField from targetFields
        where targetFields.Entity   == _entity.EntityName  &&
              targetFields.XMLField != #blank
    {
        dictField = new SysDictField(tableName2id(targetFields.TargetTable),fieldName2id(tableName2id(targetFields.TargetTable),targetFields.TargetField));
        xmlElement = xmlDocument.createElement(#column); //Column
        xmlElement.setAttribute(#name, targetFields.XMLField); //Name
        xmlElement.setAttribute(#type, enum2str(dictField.baseType())); //Type
        xmlElement.setAttribute(#isActive,  enum2str(boolean::true));
        xmlElement = childNode.appendChild(xmlElement);
        xmlElement.setAttribute(#Label, dictField.label());
        xmlElement.setAttribute(#Help, dictField.help());
    }

 

New Code:

  // Generate Target Fields
    while select Entity, XMLField, TargetTable, TargetField from targetFields
        where targetFields.Entity   == _entity.EntityName  &&
              targetFields.XMLField != #blank
    {
        dictField = new SysDictField(tableName2id(targetFields.TargetTable),fieldName2id(tableName2id(targetFields.TargetTable),targetFields.TargetField));
       // check to see if the dictField is null, if it isn’t then we can handle the field but if it is then we need to alert the user of the table and field that should be removed from the mapping
if(dictField != null)
        {
            xmlElement = xmlDocument.createElement(#column); //Column
            xmlElement.setAttribute(#name, targetFields.XMLField); //Name
            xmlElement.setAttribute(#type, enum2str(dictField.baseType())); //Type
            xmlElement.setAttribute(#isActive,  enum2str(boolean::true));
            xmlElement = childNode.appendChild(xmlElement);
            xmlElement.setAttribute(#Label, dictField.label());
            xmlElement.setAttribute(#Help, dictField.help());
        }
        else
        {
                // alert the user of the bad mapping
info("error-table: " + targetFields.TargetTable + "  field: " + targetFields.TargetField);
        }
    }

 

 

4.       Once you add this bit of code you should compile the table and rerun the target mapping. This time the window should open but will give you am info box of the bad field.

5.       Once you have this field we now need to remove the field from the mapping. However sometimes it does not exists within the visual mapping so we need manually remove it via the following

 

static void FixEmerysDMFProductIssues(Args _args)

{

    DMFTargetXML dmftargetxml;

    delete_from dmftargetxml

    where dmftargetxml.targettable == '<table name from step 3 in info box>' && dmftargetxml.targetfield == '<field name from step 3 in info box>';

}

 

6.       Whenever you open the target mapping windows for the specific entity you should no longer get the error or a msg with a table/field info that we defined in step 3.

No comments:

Post a Comment