Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Create Record from another entity

(0) ShareShare
ReportReport
Posted on by

Hello ,

I have 3 custom entity Employee, Salary Master and Salary Breakup.

Salary breakup has lookup to Salary Master and employee

Salary maters has 1 option filed Payout Type and 1 text filed Name

Option filed has 2 value earning and deduction

I have created 4 records in salary master

Basic - Earning

Pf - deduction,

hra - Earning

travel allowance - Earning

I want on creation on employee salary breakup shroud generate 4 (no of record in salary master)

Employee1 -Basic -Earning

Employee1 -Pf -deduction

Employee1 -hra -Earning

Employee1 - travel allowance - Earning

I have written following code but getting error.  Please help me with this.

Entity objmastersalary = (Entity)service.Retrieve("new_salarymaster", context.PrimaryEntityId, new ColumnSet(true));

            Entity SalaryBreakup = new Entity("new_salarybreakup");

 

            QueryExpression QueryMasterSalary = new QueryExpression("new_salarymaster");

            QueryMasterSalary.ColumnSet = new ColumnSet(true);

            EntityCollection Collecmastersalary = service.RetrieveMultiple(QueryMasterSalary);

 

            if (Collecmastersalary.Entities.Count > 0)

            {

                foreach (Entity mastersalary in Collecmastersalary.Entities)

                {

                    SalaryBreakup.Attributes["new_salarymaster"] = new EntityReference("new_salarymaster", context.PrimaryEntityId);

 

                    service.Create(SalaryBreakup);

                }

            }

*This post is locked for comments

  • RE: Create Record from another entity

    Thanks for Quick Response Ryan.  This is a part of my project, I have to add more functionality thats why i am using plugin to create these records.  

    It will be great if you can help me with plugin. Thanks :-)

  • Suggested answer
    Ryan Maclean Profile Picture
    Ryan Maclean 3,070 on at
    RE: Create Record from another entity

    Why don't you just use workflows to create the records you require?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans