0

I have created manage metadata List column which has multiple values in my list . now i want to assign the terms from power shell through CSV. Is it similar like a choice ?? I tried like this but no luck. here is my code for a drodpwn

#Appened MultiValue
$spoCtx= getContext -siteUrl $sSiteUrl -username $sUserName -password $sPassword
$spoList = $spoCtx.Web.Lists.GetByTitle($sListName)
        $spoCtx.Load($spoList) 
    $spoListItemCreationInformation = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation
                $spoListItem=$spoList.AddItem($spoListItemCreationInformation)
    $spoListItem["Country"]=AppenedMulti($Countries);
    $spoListItem.Update()
        $spoCtx.ExecuteQuery() 

    function AppenedMulti($array){

     foreach($val in $array)
                    {
                    $val= ";#" + $val.Replace(",",";#") +  ";#";              

                    }
                    return $val;
    }

function getContext($siteUrl,$username,$password)
{
    $context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
    $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
    $context.Credentials = $credentials

    return $context;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.