Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- function AddToCart() {
- var context = SP.ClientContext.get_current();
- var siteUrl = 'https://keoic.sharepoint.com/sites/ProjectSites/test/';
- var clientContext = new SP.ClientContext(siteUrl);
- var web = context.get_web();
- context.load(web);
- var sourceId = SP.ListOperation.Selection.getSelectedList();
- var source = web.get_lists().getById(sourceId);
- var oList = context.get_web().get_lists().getByTitle('Chart');
- context.load(oList);
- var selectedItems = SP.ListOperation.Selection.getSelectedItems(context);
- // alert('debut');
- for (var i in selectedItems) {
- var currentItem = source.getItemById(selectedItems[i].id);
- context.load(currentItem);
- context.executeQueryAsync(Function.createDelegate(this, test), Function.createDelegate(this, error));
- }
- function test(sender, args) {
- // alert('test');
- var itemCreateInfo = new SP.ListItemCreationInformation();
- var oListItem = oList.addItem(itemCreateInfo);
- oListItem.set_item('Title', currentItem.get_item('Title'));
- oListItem.set_item('Item', currentItem.get_item('Item'));
- oListItem.set_item('Product_x0020_Name', currentItem.get_item('Product_x0020_Name'));
- oListItem.set_item('Description', currentItem.get_item('Description'));
- oListItem.set_item('Price', currentItem.get_item('Price'));
- oListItem.set_item('Department', currentItem.get_item('Department'));
- oListItem.set_item('Branch', currentItem.get_item('Branch'));
- oListItem.update();
- oList.update();
- context.executeQueryAsync(success);
- // alert('done');
- }
- function success(sender, args) {
- alert('Added to chart!');
- // window.location.reload(true);
- }
- function error(sender, args) { alert('error'); } ""
- }
- </script>
- <input name="btnApprove" onclick="AddToCart()" type="button" value="Add To Cart"/>
Add Comment
Please, Sign In to add comment