Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested answer

Creating entity using c# code , getting error in Field service.

(0) ShareShare
ReportReport
Posted on by 15

Hi 

I am trying to create 'msdyn_workorderproduct' PRODUCT record using c# code and getting error

{"Length cannot be less than zero.\r\nParameter name: length"}

Entity entity = new Entity("msdyn_workorderproduct");
entity["msdyn_product"] = new EntityReference("product", new Guid("EA74BA0D-0521-EA11-A815-000D3A468E3E"));

entity["msdyn_name"] = "Name";

service.Create(entity);

My code is very simple but record is not creating.

  • kashiffayyaz Profile Picture
    kashiffayyaz 15 on at
    RE: Creating entity using c# code , getting error in Field service.

    I found a solution, because Work Order is mandatory field.

  • Suggested answer
    Thomas David Dayman Profile Picture
    Thomas David Dayman 11,323 on at
    RE: Creating entity using c# code , getting error in Field service.

    Its because you need to set the quantity field as well

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,432 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans