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 :
Finance | Project Operations, Human Resources, ...
Answered

How to code a Data Entity to Import table with User and DimensionAttributeValue's RecId

(1) ShareShare
ReportReport
Posted on by 265
Hi
I have created a custom table consisting only of a USERID and DIMENSIONVALUE. (RecId of the DimensionAttributeValue.RecId).
What is the correct way to create a DataEntity to be able to import records into this table but allowing the user to indicate the DisplayValue and not the recid of the DimensionValue. I have created a dataEntity and also added code to defaultrow() and persistEntity but the DimensionValue is always 0 when it is imported. 
public void defaultRow()    {        super();        if (!this.DimensionValue)        {            this.DimensionValue = DimensionAttributeValue::findByDimensionAttributeAndValue(DimensionAttribute::find(ACCRecSecParameters::find().DimensionAttributeRecId),this.DisplayValue,false,false).RecId;        }    }     ///<summary>     ///</summary>     ///<param name = /_entityCtx/></param>    public void persistEntity(DataEntityRuntimeContext _entityCtx)    {        this.skipDataSourceValidateField(fieldNum(ACCRecSecUserMappingEntity, DimensionValue), true);        if (_entityCtx.getDatabaseOperation() == DataEntityDatabaseOperation::Insert)        {            this.DimensionValue = DimensionAttributeValue::findByDimensionAttributeAndValue(DimensionAttribute::find(ACCRecSecParameters::find().DimensionAttributeRecId),this.DisplayValue,false,false).RecId;        }        super(_entityCtx);    }
 
 
 
I have the same question (0)
  • Martin Dráb Profile Picture
    239,118 Most Valuable Professional on at
    Having DimensionAttributeValue joined to your table (under Data Sources) is the correct approach (if you want to use the entity for export too or avoid code in import); make also sure that DimensionAttributeValue has Is Read Only set to Yes.
     
    You seem want to always import data for a single dimension attribute (defined in ACCRecSecParameters.DimensionAttributeRecId). If you want to avoid code, you can join it to DimensionAttributeValue in your entity definition.
    ​
    If you want to write code, I would place it to mapEntityToDataSource().
     
    Also, use the debugger to understand what's going in your code. As you see, just knowing that it doesn't produce the right result isn't sufficient information.
  • Verified answer
    Sophs@4Sight Profile Picture
    265 on at
    Thank You Martin for your response
    I was able to solve the problem by using the following code and populating the buffer for the DimensionAttributeValue.
    public void initializeEntityDataSource(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx)
        {
            if (_dataSourceCtx.name() == dataEntityDataSourceStr(ACCRecSecUserMappingEntity, DimensionAttributeValue))
            {
                DimensionAttributeValue    bufDimensionAttributeValue =   DimensionAttributeValue::findByDimensionAttributeAndValue(DimensionAttribute::find(ACCRecSecParameters::find().DimensionAttributeRecId),this.DisplayValue,false,false);
    
                _dataSourceCtx.setBuffer(bufDimensionAttributeValue);
            }
            super(_entityCtx, _dataSourceCtx);
        }
     

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 689

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 258 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans