Avatar of BigBlueMan
BigBlueMan
Flag for United Kingdom of Great Britain and Northern Ireland asked on

MS CRM 4.0 Programming Worlflows in C# for bulk update of customized column.

Hi
I'm a beginner in the C# language, but trying to progamme a plugin using the CRM SDK to be used iin workflow to update a number of Lead records at a given time of the day. I have the basic recurring workflow (created with CRM) that can wait to execute an operation at a specific time, but am struggling slighlty on the C# plug in side..

What I'm trying to achieve;
1. a workflow runs at a given time during the day (e.g. 5pm) (DONE).
2. it updates a column in several records on the lead table, called for example, new_test_field, that I've created. It will only update the column to a value, where the createdon value is set to the current day..

I've create the workflow infrastucture to wait for execution at 5pm, but now struggling with the C# plugin... Downloaded a simlar example from the Web which updates the status on the account entity but was wondering if this can be adapted to update the customized column as I indicated.  Example is attached.

thanks

Phil



c-code.txt
Microsoft DynamicsC#

Avatar of undefined
Last Comment
BigBlueMan

8/22/2022 - Mon
Dennis Aries

In your columnset, instead of adding 'statecode', add 'new_text_field'.
Update the field as needed right before the crmService.Update(acc)-statement and you should be set.
BigBlueMan

ASKER
Hi dijaries

Thanks for the reply....The VS2008 intellisense didn't seem to recognise the new field name, which confused me... I'll try it and build the solution and see what happens.
Dennis Aries

Refresh your web-reference when you alter your entities to incorporate your chances and allow intellisense to work with it.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
BigBlueMan

ASKER
Thanks for the information.... Tried all that, but still not showing my new attribute... However, have noticed that all my customized columns which are prefixed with 'new_' do not appear anyways...

Apologies but C# is not my tradtional programming language (am from a Perl background)...

In my version of the final foreach loop below, i'm querying lead entitiy.. now I assume as my new columns are in the leadextension table this is why they do not appear.... Is this the issue ???
Any suggestions ?

foreach (lead ld in crmService.RetrieveMultiple(query).BusinessEntities)
{
...
...
}
Dennis Aries

By 'Refresh', I meant 'update' the webservice (rightclick on the webservice-reference and select update).
You are using the information retrieved from the webservice, so you are using the metadata database which should return you all the attributes unless you stated otherwise in your query. This should include the leadextension table.
Since I assume you did update the reference, can you post your query?
BigBlueMan

ASKER
Hi Dijares

Have added a screen print of my environment and the sample code... I've just started to learn C# and am due to get on a course shortly, so apologise again for my ignorance...

thanks

Phil
badcode.doc
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
BigBlueMan

ASKER
Hi djjaries

Does you have an extra advice on this one ?

rgds

Phil
ASKER CERTIFIED SOLUTION
Dennis Aries

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
BigBlueMan

ASKER
Ok thanks will take a look at that stuff..