Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Microsoft CRM web service create record "Object reference not set"

16 views
Skip to first unread message

Jeffry van de Vuurst

unread,
Feb 28, 2006, 2:53:15 AM2/28/06
to
defaultuomid is of type Lookup. You create and fill a lookup like this:
Lookup lookup = new Lookup();
lookup.Value = user.UserId;
lookup.type = EntityName.systemuser.ToString();So in your case you should do
something like:
product.defaultuomid = new Lookup();
product.defaultuomid.Value = yourGuid;
product.defaultuomid.type = entityname that the lookup references,
EntityName.uom.ToString()

HTH,

--
Jeffry van de Vuurst
CWR Mobility
www.cwrmobility.com
--
"Rosh" <Ro...@discussions.microsoft.com> wrote in message
news:6A014B22-F0C7-4DBF...@microsoft.com...
> Am attempting to add a product using web services. Code is quite strait
> forward but I am stuck on one thing.
>
> In the product base there are two required fields of type
> uniqueidentifier.
> These are defaultuomid and defaultuomscheduleid.
>
> Although I have copied the values direct form the source table ID fields,
> I
> get the following error when I run the code.
>
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
>
> Line 27: product.defaultuomid.Value = new
> guid("25B37C23-5E94-DA11-8CC2-000C412218DC")
>
> My code looks like this
> 23 Dim product as new product
> 25 product.name = "test"
> 26 product.productnumber = "test"
> 27 product.defaultuomid.Value = new
> guid("25B37C23-5E94-DA11-8CC2-000C412218DC")
> 28 product.defaultuomscheduleid.Value = new
> Guid("24B37C23-5E94-DA11-8CC2-000C412218DC")
>
> Dim productGuid As Guid = service.Create(product)
>
> There must be something I don't understand about guid's
>
> Can somebody lead me in the right direction?
> Help is most appreciated
>


Rosh

unread,
Feb 28, 2006, 2:24:04 PM2/28/06
to
Thankyou so much. I should have realised that

cocde ended up like

product.defaultuomid = new Lookup()
product.defaultuomid.Value = new guid("25B37C23...")
product.defaultuomid.type = "uomBase"

0 new messages