Last active
October 30, 2017 04:00
-
-
Save Salvodif/f28175fd07db647109cc to your computer and use it in GitHub Desktop.
underscore string sprintf example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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