dynamics crm - Set EntityReference attribute to not working Microsoft.Xrm.Data.PowerShell -
i cannot update theme powershell using microsoft.xrm.data.powershell.
the following code not working:
#get theme $res = get-crmrecords -conn $connection -entitylogicalname theme -filterattribute name -filteroperator eq -filtervalue $nameoftheme -fields themeid, name, logoid, isdefaulttheme, logotooltip, navbarbackgroundcolor, navbarshelfcolor, headercolor, globallinkcolor, selectedlinkeffect, hoverlinkeffect, processcontrolcolor, defaultentitycolor, defaultcustomentitycolor, controlshade, controlborder $importedtheme = $res.crmrecords[0] #get resource web $reslogo = get-crmrecords -conn $connection -entitylogicalname webresource -filterattribute name -filteroperator eq -filtervalue "logoname" $importedlogo = $reslogo.crmrecords[0] $erlogo = (new-crmentityreference -entitylogicalname webresource -id $importedlogo.webresourceid) #update theme $importedtheme.logoid = $erlogo set-crmrecord -conn $connection -crmrecord $importedtheme this given error:
impossible d'appeler une méthode dans une expression null. au caractère c:\users\il...ll\microsoft.xrm.data.powershell.psm1:628 : 16 + if($crmfieldvalue -eq $null) + ~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : invalidoperation : (:) [], runtimeexception + fullyqualifiederrorid : invokemethodonnull le cast spécifié n'est pas valide. au caractère c:\users\il...ll\microsoft.xrm.data.powershell.psm1:773 : 9 + throw $conn.lastcrmexception + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : operationstopped: (:) [], invalidcastexception + fullyqualifiederrorid : le cast spécifié n'est pas valide.
i think problem comes verification in part of code of xrm.data.powershell:
if($crmfieldvalue -eq $null) { write-host "$crmfieldvalue -eq $null" $newfield.type = [microsoft.xrm.tooling.connector.crmfieldtype]::raw $value = $null } i cannot find solution. have idea?
Comments
Post a Comment