Answered by:
Remove lookup field value via web-service doesnt work!

Question
-
I have a solution that has a list of drivers and a list of truckloads. The driver (contact) has a property that is a Lookup that points to a truckload. Once a truckload has been delivered it gets deleted from CRM. During the delete I set the lookup in the driver to null:
driver.new_truckload = null;
If I look at a list of drivers that shows the truckload property that will display properly - drivers that had truckloads delete will look correct. But if you open the driver the Truckload field will have a link to the truckload that was deleted! If you click the link you get an error page saying the truckload doesnt exist.
What gives? Is there something special I need to do to make this blasted thing go away?
EAI ArchitectWednesday, May 27, 2009 8:52 PM
Answers
-
Jake,
Before you open a support incident with Microsoft, try this code. This is assuming you are writing .net code in C#.
Driver d = new Driver(); d.new_driverid = new Key(); d.new_driverid.Value = new Guid("some driver id"); d.new_truckload = new Lookup(); d.new_truckload.IsNull = true; d.new_truckload.IsNullSpecified = true; CrmService.Update(d);
I wrote the code in VB.net and translated on the fly, but I know it works.- Marked as answer by Jake Watkins Monday, June 1, 2009 9:48 PM
Thursday, May 28, 2009 10:21 PM
All replies
-
Hi Jake,
I am not much sure about the scenario, as I am not sure how this is happening. However, how about checking for truckload via an AJAX call on page load?
Also did you try setting it to null and then delete the truckload?
Regards,
Chinmay
http://metrix.blogspot.comWednesday, May 27, 2009 8:59 PM -
thanks for the quick response.
the Lookup on the driver is cleared before the truckload gets deleted.
We have a script on the driver screen that tests to see if the truckload exists and if it doesnt clears off the truckload. However, that happens after the fact. My client uses the truckload property on the driver to determine which drivers need to be given truckloads. They have a filter on the list screen (I do backend stuff, so I'm not up on the UI terms right now) that will show a list of drivers that don't have a truckload assigned (truckload doesnt have a value). If you have to open the driver to clear off the truckload it sort of defeats the point of the filter.
For further clarification the information about the truckload's status comes from a separate system. BizTalk is getting the information and then updating CRM via an AIC I wrote that talks to the CRM web-service (for the BizTalk literate - doing all the lookups and stuff would have made orchestrations massively ugly).
Anyway, is getting Lookup objects to go away some type of secret thing? Do I have to get past a secret level of Halo3 before the secret is revealed?
EAI Architect- Proposed as answer by Chinmay Patel Wednesday, May 27, 2009 9:36 PM
Wednesday, May 27, 2009 9:07 PM -
I have a solution that has a list of drivers and a list of truckloads. The driver (contact) has a property that is a Lookup that points to a truckload. Once a truckload has been delivered it gets deleted from CRM. During the delete I set the lookup in the driver to null:
driver.new_truckload = null;
If I look at a list of drivers that shows the truckload property that will display properly - drivers that had truckloads delete will look correct. But if you open the driver the Truckload field will have a link to the truckload that was deleted! If you click the link you get an error page saying the truckload doesnt exist.
What gives? Is there something special I need to do to make this blasted thing go away?
EAI Architect
Hi, Jake.
Go Settings - Customization - Customize Entities, open your driver entity, Open 1:N relationship tab, Open the relationship record between driver and truckload entity. Configure Delete rule as 'Drop Link'. When truckload entity is deleted - all lookups in driver entity automatically will be cleared.
I hope this will help you.
Truth is opened the prepared mind My blog - http://a33ik.blogspot.comWednesday, May 27, 2009 9:18 PMModerator -
Can you post the code while you are setting the driver.new_truckload = null;
Why i am wonderring is its an lookup field and are you sure you are setting the value properly or not?Wednesday, May 27, 2009 9:19 PM -
Hi Jake,
It should be driver.new_truckload.DataValue = null;
Regards,
Chinmay
http://metrix.blogspot.comWednesday, May 27, 2009 9:35 PM -
I'll give a33ik's solution a shot tomorrow.
I'll also post up more of the code involved. However, it's my client's stuff so I'm trying to be some what careful w/ their IP. I'm dealing with two related data feeds from another system that gets fed to CRM where driver's get dispatched to move the truckloads to their destination. Once a driver is matched with a truckload a message is sent back to the source system where work is done and then both the truckload and driver records are updated causing them to come back to CRM again where they get updated. In the driver's case we indicate that the driver is assigned a load. In the truckload's case, because it is assigned a driver so it doesnt need to be dispatched anymore, it gets deleted. So simply put, additional code beyond the onliner won't make a lot of sense unless you can see the entire chain of events, which I can't really provide for the reason stated above.
If neither a33ik's or Chinmay's solution fixes this I'll create a reproduction to send to PSS to see if they can figure out what is going on. I'll post that. Heck I might build it this weekend anyway and make an article out of it. The amount of BizTalk/CRM stuff I've done over the past 2 months has given me such a headache. The upside is that it's probably the fastest way to develop expertise in the product.
EAI ArchitectThursday, May 28, 2009 2:21 AM -
Welp - nobody wins the starbucks. None of the suggestions work.
I created a reproduction to use when I open a support incident with Microsoft. You can grab a copy from here from my web-site. Just load the entities then compile and run the test harness I've provided and follow the directions in the word doc.
The good news to me is that I was able to reproduce the same problem in a seperate environment. Bad news is that I was able to reproduce the same problem in a seperate environment. Hopefully it's a really easy thing to get around.
More suggestions would be apperciated.
EAI ArchitectThursday, May 28, 2009 8:19 PM -
Jake,
Before you open a support incident with Microsoft, try this code. This is assuming you are writing .net code in C#.
Driver d = new Driver(); d.new_driverid = new Key(); d.new_driverid.Value = new Guid("some driver id"); d.new_truckload = new Lookup(); d.new_truckload.IsNull = true; d.new_truckload.IsNullSpecified = true; CrmService.Update(d);
I wrote the code in VB.net and translated on the fly, but I know it works.- Marked as answer by Jake Watkins Monday, June 1, 2009 9:48 PM
Thursday, May 28, 2009 10:21 PM -
what other language would a sane person use? :D
And your answer is quite right. Sorry CRM team, but that just seems nutz and counter intuitive. But oh well, code works and customer is all grins and giggles so I'll live with it.
Thanks to everybody who helped out. Hopefully I can return the favor in the future.
edit - and I owe you a Starbucks.
EAI ArchitectMonday, June 1, 2009 9:47 PM