cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
timwelch
Regular Visitor

Dynamics 365 - Unable to create multiple records from FetchXML filter

Hi all,


I'm very new to flow and perplexed as to how it should work with Dynamics 365.

 

I'm using the CDS Connector and FetchXML to filter Account records that don't have corresponding Contacts and then create new Contacts for these Accounts. (As per this article)

 

The filter works well and I can construct an HTML email and send it to myself but if I try to create new records nothing happens... I suspect I'm simply constructing it wrong but I can't seem to find any documentation on how... 

Annotation 2020-02-19 102158.png

 

Any assistance greatly appreciated.

 

Tim Welch

 

1 ACCEPTED SOLUTION

Accepted Solutions
timwelch
Regular Visitor

Re: Dynamics 365 - Unable to create multiple records from FetchXML filter

SOLUTION: 

You definitely need to use the "Common Data Service (Current Environment)" - this isn't the first CDS option when searching for it.

 

When creating a Contact you need "Account Name (Accounts)" to be /accounts(@{items('Apply_to_each')?['accountid']}) as per...

Annotation 2020-03-05 103456.png

View solution in original post

9 REPLIES 9
Super User
Super User

Re: Dynamics 365 - Unable to create multiple records from FetchXML filter

@timwelch 

Hi there.  So here's what I think is happening.  For the contact entity, the Last Name is typically required.  And the "Full Name" field is usually an aggregate of the First Name and Last Name.  

 

Try dropping your dynamic value for Account Name into the Last Name field instead and see if that changes your results.

 

Keep us posted.

-Ed

 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

Super User
Super User

Re: Dynamics 365 - Unable to create multiple records from FetchXML filter

Hi @timwelch 

 

Your first step action trigger is update now. If you want to trigger for create and update then select Create or Update.

 

image.png



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
timwelch
Regular Visitor

Re: Dynamics 365 - Unable to create multiple records from FetchXML filter

OK, it appears that my main issue was not using the Common Data Service (Current Environment) for Create Record as per... 

Annotation 2020-02-19 141859.png

However I now get another issue when the flow runs... "Input string was not in a correct format."

{
  "error": {
    "code": "0x0",
    "message": "Input string was not in a correct format.",
    "innererror": {
      "message": "Input string was not in a correct format.",
      "type": "System.FormatException",
      "stacktrace": "   at System.Text.StringBuilder.FormatError()\r\n   at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)\r\n   at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)\r\n   at System.String.Format(IFormatProvider provider, String format, Object[] args)\r\n   at Microsoft.Crm.CrmHttpException..ctor(HttpStatusCode statusCode, String message, Object[] args)\r\n   at Microsoft.Crm.Extensibility.OData.CrmEdmEntityReference.CreateCrmEdmEntityReference(Uri link, IEdmModel edmModel, CrmODataExecutionContext context, EntitySetSegment& entitySetSegment)\r\n   at Microsoft.Crm.Extensibility.OData.TypeConverters.EdmEntityTypeConverter.SetNavigationPropertyToXrmEntity(Entity entity, IEdmProperty edmProperty, EntityRelationship entityRelationship, Object propertyValue, Nullable`1 role, String operationName)\r\n   at Microsoft.Crm.Extensibility.OData.TypeConverters.EdmEntityTypeConverter.ConvertToCrmTypeInternal(EdmEntityObject edmTypeValue, String operationName)\r\n   at Microsoft.Crm.Extensibility.OData.TypeConverters.EdmTypeConverterBase`2.ConvertToCrmType(Object edmTypeValue, String operationName)\r\n   at Microsoft.Crm.Extensibility.OData.EdmTypeConverter.ConvertToCrmEntity(EdmEntityObject edmEntity, EntityReference entityReference, IEdmModel edmModel)\r\n   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)\r\n   at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.CreateEdmEntity(CrmODataExecutionContext context, String edmEntityName, EdmEntityObject entityObject, Boolean isUpsert)\r\n   at Microsoft.Crm.Extensibility.OData.EntityController.PostEntitySetImplementation(String& entitySetName, EdmEntityObject entityObject)\r\n   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)\r\n   at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
    }
  }
}

 

I'm not sure if anyone can decipher this but I'd be grateful for any further pointers.

 

Cheers, Tim

timwelch
Regular Visitor

Re: Dynamics 365 - Unable to create multiple records from FetchXML filter

Hey @abm - to be honest I don't care how the flow is triggered; with Update as my trigger I can simply update a random Account and it will run.

 

What I'm more worried about is the resulting "Apply To Each" - Create A New Record since I'm filtering Accounts for missing Contacts and then wanting to create those Contacts.

 

Hope this explains further what I'm trying to achieve.

Super User
Super User

Re: Dynamics 365 - Unable to create multiple records from FetchXML filter

Hi @timwelch 

 

Thanks for your reply.

 

What is your List filter? Also create contact did you set the lastname? Couldn't see that from the screenshot. 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
timwelch
Regular Visitor

Re: Dynamics 365 - Unable to create multiple records from FetchXML filter

Cheers for your assistance @abm but it appears that my issue is caused by the way I am populating "Account Name (Accounts)" when the new Contact record is created.

 

I can run this flow to create Contacts without the "Account Name (Accounts)" field and this works fine (apart from the new Contact is not associated with an Account)

 

When I populate it using "Account Name" the flow fails with...

 

 

"message": "Resource not found for the segment 'Bob User'.", 

 

 

 
Super User
Super User

Re: Dynamics 365 - Unable to create multiple records from FetchXML filter

Hello @timwelch ,

In your picture with the create a new record action.

The field named Contact Type Value = Standard.
What other options are available to you in the drop down?
Is account an option?

—Josh
If you like my post please hit the "Thumbs Up" -- If my post solved your issue please "Mark as a Solution" to help others




Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up ?


Proud to be a Flownaut!





timwelch
Regular Visitor

Re: Dynamics 365 - Unable to create multiple records from FetchXML filter

Hi @Jcook  - that field is simply our custom identifier for the type of contact we're adding.

 

My issue is definitely the format of "Account Name (Accounts)" and I don't seem to be about to find any documentation as to what this should be so I'm currently working my way through various scenarios when I get time.

 

Cheers, Tim

timwelch
Regular Visitor

Re: Dynamics 365 - Unable to create multiple records from FetchXML filter

SOLUTION: 

You definitely need to use the "Common Data Service (Current Environment)" - this isn't the first CDS option when searching for it.

 

When creating a Contact you need "Account Name (Accounts)" to be /accounts(@{items('Apply_to_each')?['accountid']}) as per...

Annotation 2020-03-05 103456.png

View solution in original post

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (8,333)