0

I need jquery code which can copy the data from one column(look up column) and populate into other column (single text line) in the same list in sharepoint 2010.

  • Are you trying to update the value when you submit a new item or edit an old one? Are you trying to update items that are somewhere in the background (i.e. you don't have the new or edit form open)? – John-M Aug 5 '15 at 11:22
0

If you really need to implement such a copy mechanism using javascript you can use the javascript Client Script Object Model also called JSOM for this task. You can find a description and examples here: https://msdn.microsoft.com/en-us/library/office/hh372944(v=office.14).aspx Using JSOM will only work if you're calling that script from within SharePoint.

Should you need to execute that script outside of that SharePoint site, you could use the SPServices library which uses SharePoint webservices in the background: http://spservices.codeplex.com/

May I ask what the purpose of this copy is though? Depending on what you need it for, you could also just use a calculated column to "display" the value of the other column, but I also wouldn't see much purpose of that. :)

| improve this answer | |
  • Thanks for this info. I dont have much idea on code, so tries the codes provided in the link by just replacing the column name and ID to mine one, but it didnot work. I can do this by using calculated column but that will not resolve my issue. – Kanan Aug 5 '15 at 12:44
  • What is the issue you're trying to solve by this? – Swiss Dev Aug 5 '15 at 12:44
  • Actually I am doing color coding in sharepoint 2010 with help of calculated columns. The colors to be selected based on value of a lookup column. As I am not able to select lookup column in calculated column formula, I need some jquery which will copy data from my lookup column and paste into another single text column. And that text column I can use for my calculated column. Could you please help me with the jquery code? – Kanan Aug 5 '15 at 12:47
  • Note: I dont have sharepoint designer not PowerShell script – Kanan Aug 5 '15 at 12:48
  • Ah! If you're gonna use jquery already, just do the color coding with jquery, based on the value of the lookup column. This will be straight-forward and would make more sense, rather than making a copy of the field and then using the calculated column. – Swiss Dev Aug 5 '15 at 12:49
0

This should do it:

function PreSaveItem() {
var N1 = $("select[title$='LookUpField'] option:selected").text();
$ ( "input[title='SingleTextField']").val(N1);
return true;
}
| improve this answer | |

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.