Skip to main content

Notifications

Announcements

No record found.

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

Getting wrong RecId in Insertentitydatasource method on data entity

(0) ShareShare
ReportReport
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 230,445 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 230,445 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans