web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

I´m Trying to Write a String in a Field C#

(0) ShareShare
ReportReport
Posted on by

using System;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
using Microsoft.Xrm.Sdk.Query;
using System.Text.RegularExpressions;

namespace ActivityLibrary1
{
    public sealed class KleinerTest : CodeActivity
    {
        protected override void Execute(CodeActivityContext executionContext)
        {
            ITracingService tracingService = executionContext.GetExtension<ITracingService>();
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
            tracingService.Trace("test");
            Guid ID = context.PrimaryEntityId;
            Entity Entity = service.Retrieve("account", ID, new ColumnSet(true));
            string input = "Testobjekt";
            Entity["new_historie"] = input;
            service.Update(Entity);
        }
    }
}

_____________________________________________________________________________

Error:

Unexpected exception from plug-in (Execute): ActivityLibrary1.KleinerTest: System.AggregateException: One or more errors occurred.

Unhandled Exception: Microsoft.Crm.CrmException: Unexpected exception from plug-in (Execute): ActivityLibrary1.KleinerTest: System.AggregateException: One or more errors occurred.
   at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context)
   at Microsoft.Crm.Workflow.Services.ProxyCustomActivity.Execute(CodeActivityContext executionContext)

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    I want to get all fields because i´m just testing

    It is a Custom Workflow activity

  • Verified answer
    Community Member Profile Picture
    on at

    Probably error not related to string field (also, check that new_historie is really string field, just to be sure) . You retrieved all columns and it means that when you update record you will update all retrieved fields with same value. And it means that all workflows and plugins related to this fields will be triggered.

    So:

    * Try to update only  new_historie field. It there is no error, it means error related to other fields

    * Check all plugins and workflows, determine what is triggered when you update entity, try to locate your error.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans