Skip to content

Instantly share code, notes, and snippets.

@Salvodif
Last active October 30, 2017 04:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Salvodif/f28175fd07db647109cc to your computer and use it in GitHub Desktop.
Save Salvodif/f28175fd07db647109cc to your computer and use it in GitHub Desktop.
underscore string sprintf example
function copySelectedProposal ( selectedProposal, dstParam, succeededCallback, failedCallback ) {
if ( selectedProposal == null )
return;
var x = {
absUrl : _spPageContextInfo.siteAbsoluteUrl,
relUrl : _spPageContextInfo.webServerRelativeUrl,
dst : dstParam,
proposal : selectedProposal
};
x.filename = selectedProposal.substring ( selectedProposal.lastIndexOf ( "/" ) + 1 );
x.srcUrl = _.str.sprintf ( "%(absUrl)s/_api/web/getFileByServerRelativeUrl('%(proposal)s')/$value", x);
x.dstUrl = _.str.sprintf ( "%(absUrl)s/%(dst)s/_api/web/getFolderByServerRelativeUrl('%(relUrl)s/%(dst)s/LibUploadedFiles')/Files/add(url='%(filename)s')", x );
console.debug ( x );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment