Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Fill lookup field with data using PowerShell

$
0
0

Hi,

I receive a .csv file daily and use PowerShell to update/insert the information into CRM.

I am changing the field new_endcustomer from string to lookup because I want to see only related information in another form (account form) but it needs some kind of link to do that of course. But now Microsoft Dynamics gives me the error when I run my script:

"Exception calling "Update" with "1" argument(s): "System.InvalidCastException: Microsoft Dynamics CRM has experienced an error."

I can't post the entire script here, it's too long, but the 2 lines that I feel cause the issue are these:

$entity.Attributes["new_endcustomer"] = $_."End Customer"
$service.Update($entity)

The value that's in the end customer field in the csv matches the name of the Account in my CRM (which the lookup field is linked to) but I am still getting this error. I can find absolutly nothing useful online so I am hoping that I can receive some guidance as on how to solve this issue here.

How can I fill up a lookup field using PowerShell into Microsoft CRM 2016?


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>