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

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
AS-17030037-0 Profile Picture

AS-17030037-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans