1

here is the problem where i am able to use the object of AssetPicker to load it as a dialog box on my button click by refering the below solution

Opening and closing AssetPortalBrowser.aspx in SharePoint modal popup ..but the issue is that when ever i clicked on "Insert" action it give the below error.. enter image description here

can any one have idea why ? and pls solution for it .. Urgent..

UPDATE below is the simple code i have placed in my CEWP


var testobj = new AssetPickerConfig(); obj.CurrentWebBaseUrl = _spPageContextInfo.webAbsoluteUrl; obj.ReturnCallback = getPickertUrl;

function getPickertUrl(url) {
    console.log(url);
    document.getElementById('txtURL').value = url;
}

function openPicker(){
    APD_LaunchAssetPicker(testobj);
}

3
  • From the error its look like you are missing the callback function, i.e. commonModalDialogClose. Commented Nov 27, 2017 at 8:06
  • yes , but as i am not over-writing any function of AssetBrowser.aspx page ..why its breaking !!!.. it should work .. Commented Nov 27, 2017 at 8:18
  • I am not sure about why its breaking without seeing your code. But I had provided the solution below. If that was helpful, please mark it as answer. Commented Nov 28, 2017 at 7:48

1 Answer 1

0

Kindly follow the below mentioned solution. I had test this code in IE and FireFox and its working fine there. There is also an attached demo of the same.

In my code, I am using a global variable obj which is not a best practice, so modify the code accordingly. Its just for the reference.

<div>
    <input type="text" id="pickerControl" width="100%" style="width:100% !important; margin-bottom: 20px" />
    <input type="button" value="Pick" onclick="openPicker()" />

</div>

<script src="/sites/test/_layouts/15/AssetPickers.js"></script>

<script>
    var obj = new AssetPickerConfig();
    obj.CurrentWebBaseUrl = _spPageContextInfo.webAbsoluteUrl;
    obj.ReturnCallback = getPickertUrl;

    function getPickertUrl(url) {
        console.log(url);
        document.getElementById('pickerControl').value = url;
    }

    function openPicker(){
        APD_LaunchAssetPicker(obj);
    }
</script>

Demo

The demo video is uploaded to my GDrive. Follow this url to check it out. https://drive.google.com/file/d/1iYjISDVm-B5EjTf4G0-5IKHZnjhWbEhe/view?usp=sharing

4
  • thanks for providing the solution , but i have the same issue even with you solution . Commented Nov 29, 2017 at 10:21
  • can you explain in details, what is your environment, and the browser version? Can you check the same functionality on different browser? Commented Nov 30, 2017 at 10:41
  • hi, i have checked in all browser but facing the same error .. not sure if it is because of any existing angular JS on my site .. but i have to implement that functionality in that environment only .. so need solution of that error ..any help will be greatly appreciated .. Commented Dec 4, 2017 at 6:14
  • Without debugging its hard to say what is causing the problem. To start with, you can open browser console (dont debug anything now), and just paste AssetPickerConfig into console. If it says undefined then there is the issue with script loading. If that works fine, now debug the function call where you had written above code. In that function in beginning write debugger;, to initiate debugging and do the same thing i.e. in console paste AssetPickerConfig. If both works fines then angular is creating some problem. First try this and see if object is accessible or not. Commented Dec 6, 2017 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.