0

I am trying to add items to a list from a CSV script. I have imported the code and established the variables and even test to ensure that the SP information is accurate.

The following code does not exit.

PS C:\Users\sharepoint> foreach ($item in $imp) {

>> $new = $list.items.Add();

>> $new['Title'] = $item.Title;

>> $new['Body'] = $item.SectionTitle;

>> $new['StartDate'] = $item.Started;

>> $new['Assignedto] = $item.ResponsibleTranslate;

>> $new.Update();

>> }

>>

>>

I have selected enter several times and I cannot get the foreach to close.

I have tested foreach using "Foreach ($item in $imp) {echo $item}. This works properly.

It only decides to not work when I am trying to reference the information.

  • Can you use ISE and add a breakpoint on $new.Update()? It might give you a better idea of what is going on. – Bunzab Feb 10 '15 at 17:44
1

It would be because of this: $new['Assignedto] = $item.ResponsibleTranslate;

The internal name of the Assigned To column would be $new['AssignedTo'] = $item.ResponsibleTranslate;, you are also missing the closing apostrophe.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.