Skip to main content

Notifications

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

  • Verified answer
    Community Member Profile Picture
    on at
    RE: I´m Trying to Write a String in a Field C#

    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.

  • Community Member Profile Picture
    on at
    RE: I´m Trying to Write a String in a Field C#

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

    It is a Custom Workflow activity

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
dkrishna Profile Picture

dkrishna 6

Featured topics

Product updates

Dynamics 365 release plans