I have a scenario where when I open a newform for one list, I want it to create a new record in another list. In list 1 the field I want it to copy is ‘DocID’ and this would go into Title of list 2. I would like to use javascript to do this but don’t know enough about SharePoint (my guess) to figure it out.
Any assistance would be greatly appreciated!
function createNew() { var clientContext = new SP.ClientContext(siteUrl); var oList = clientContext.get_web().get_list().getByTitle('LIST2'); var itemCreateInfo = new SP.ListItemCreationInformation(); this.oListItem = oList.addItem(itemCreatInfo); oListItem.set_item('Title','Hello World!'); oListItem.update(); clientContext.load(oListItem); }
Above is just a same and it does add a new record with “Hello World!” in the Title but when I try to change that to a variable, like the DocID in the existing list, it comes up blank.
I don’t want to use workflows because I need the item in the 2nd list before the 1st item is saved.