Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

Getting wrong RecId in Insertentitydatasource method on data entity

Posted on by 56

I have created a custom data entity with name xyz_currentforecastdataentityV2. I am publishing a record  through excel using my entity in which  there is field with the name ''Name''. I have requirement when I give the value in Name field it should get the RecId value from ResourceView and assign that value to my custom table xyz_CurrentForeCastTable (same table is being used in my custom entity xyz_currentforecastdataentityV2) in field  ProjResource. As shown in below code

   public boolean insertEntityDataSource(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx)
    {
        boolean ret;         
        RESOURCEVIEW                 resourceView;
        xyz_CURRENTFORECASTTABLE     currentForecastTable;
        
        select RecId from resourceView          
           where resourceView.Name == this.Name;
           
        currentForecastTable.ProjWorkerResource = resourceView.RecId;
        
        ret = super(_entityCtx, _dataSourceCtx);
        return ret;

    }

I have tried using this code but I am retrieving wrong RecId. I tried the same query in SQL and runnable class there I am getting the right value of RecId.

  • Martin Dráb Profile Picture
    Martin Dráb 229,918 Most Valuable Professional on at
    RE: Getting wrong RecId in Insertentitydatasource method on data entity

    I suggested no solution - I asked you some questions and explained why they're relevant. Could you answer them, please?

  • Awais Qurni Profile Picture
    Awais Qurni 56 on at
    RE: Getting wrong RecId in Insertentitydatasource method on data entity

    I already try this solution but still not fixed my RecId issue.

  • Martin Dráb Profile Picture
    Martin Dráb 229,918 Most Valuable Professional on at
    RE: Getting wrong RecId in Insertentitydatasource method on data entity

    Is Name guaranteed to be unique inside ResourceView? If not, the database can give you any of the records with this name.

    Also, did you take DataAreaId into account in your SQL code and did you use the same company when running your runnable class as the one used for the import? If not, you're comparing different things and you're expected to get different results.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,113 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans