Override standard Lookup and construct tree structure in Category Id field. and Process while Modifying KGSPMICategoryHierarchy field

Override standard Lookup and construct tree structure in Category Id field. and
 Process while Modifying KGSPMICategoryHierarchy field



class KGSPMIEcoResProductParametersEventHandler
{
    /// <summary>
    /// Created by Naren on 11/12/2019
    /// Project: KGSPMIProdMasterToMagento
    /// Override standard Lookup and construct tree structure in Category Id field.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormControlEventHandler(formControlStr(KGSPMIIntegrationParameters, MagentoHiearchy_MagentoCategory), FormControlEventType::Lookup)]
    public static void MagentoHiearchy_MagentoCategory_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        FormControlCancelableSuperEventArgs event = e as FormControlCancelableSuperEventArgs;
        FormControl                         productCategory = sender.formRun().design().controlName(formControlStr(KGSPMIIntegrationParameters, MagentoHiearchy_MagentoCategoryHierarchy));
        EcoResCategoryHierarchyId           ecoResCategoryHierarchyId = str2Int64(productCategory.valueStr());
        if(ecoResCategoryHierarchyId)
        {
            EcoResCategoryHierarchy  categoryHierarchy  = EcoResCategoryHierarchy::find(ecoResCategoryHierarchyId);
            EcoResCategory::lookupCategoryHierarchy(sender,categoryHierarchy);
        }

        event.CancelSuperCall();
    }
    /// <summary>
    /// Created by Naren on 11/12/2019
    /// Project: KGSPMIProdMasterToMagento
    /// Process while Modifying KGSPMICategoryHierarchy field.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormControlEventHandler(formControlStr(KGSPMIIntegrationParameters, MagentoHiearchy_MagentoCategoryHierarchy), FormControlEventType::Modified)]
    public static void MagentoHiearchy_MagentoCategoryHierarchy_OnModified(FormControl sender, FormControlEventArgs e)
    {
        FormDataSource              ecoResProductParamters_ds = sender.formRun().dataSource();
        FormControl                 productCategory = sender.formRun().design().controlName(formControlStr(KGSPMIIntegrationParameters, MagentoHiearchy_MagentoCategoryHierarchy));
        EcoResCategoryHierarchyId   ecoResCategoryHierarchyId = str2Int64(productCategory.valueStr());
        if(ecoResCategoryHierarchyId)
        {
            ecoResProductParamters_ds.object(fieldnum(KGSPMIIntegrationParameters, MagentoCategory)).setValue('');
            ecoResProductParamters_ds.object(fieldnum(KGSPMIIntegrationParameters, MagentoCategory)).allowEdit(true);
        }
        else
        {
            ecoResProductParamters_ds.object(fieldnum(KGSPMIIntegrationParameters, MagentoCategory)).setValue('');
            ecoResProductParamters_ds.object(fieldnum(KGSPMIIntegrationParameters, MagentoCategory)).allowEdit(false);
        }  
    }
}

Comments

Popular posts from this blog

Data entites method calling sequence in D365FO

How to Extend Sales Order Update Functionality to Custom Fields in D365 Finance and Operations

To generate dimension and find the account value - KGSPMIDimensionUtility