Binding the adf-webscript-get component into a button

cancel
Showing results for 
Search instead for 
Did you mean: 
Active Member II

Binding the adf-webscript-get component into a button

Jump to solution

Is there a way to bind the adf-webscript-get component into a button that is in a dropdown? Because right now the calling of the webscript is happening on page reload, and what I want to do is run that when the button is clicked. Cheers!

<adf-sidebar-action-menu>

    <mat-icon sidebar-menu-title-icon>arrow_drop_down</mat-icon>

    <div sidebar-menu-expand-icon>

        <mat-icon>add</mat-icon>

        <span>Create...</span>

    </div>

    <div sidebar-menu-options>

        <button met-menu-item

            [adf-create-folder]="getDocumentListCurrentFolderId()"

            (success)="onFolderCreate($event)"

            title="Create New Folder">

            <mat-icon>folder</mat-icon>

            <span>Folder</span>

        </button>

        <button mat-menu-item>

            <adf-webscript-get

                [contextRoot]="alfresco"

                [servicePath]="service"

                [scriptPath]="'googledocs/createContent?contenttype=document&parent=workspace://SpacesStore/8f2105b4-daaf-4874-9e8a-2152569d109b'"

                [contentType]="HTML">

        </adf-webscript-get>

        <span>Google Docs Document...</span>

        </button>

    </div>

</adf-sidebar-action-menu>

1 Solution

Accepted Solutions
Highlighted
Alfresco Employee

Re: Binding the adf-webscript-get component into a button

Jump to solution

Hi, what the webscript does :

alfresco-ng2-components/webscript.component.ts at development · Alfresco/alfresco-ng2-components · G... 

you could associate the same call at on whatever onClick event of your app

View solution in original post

8 Replies
Highlighted
Alfresco Employee

Re: Binding the adf-webscript-get component into a button

Jump to solution

Hi, what the webscript does :

alfresco-ng2-components/webscript.component.ts at development · Alfresco/alfresco-ng2-components · G... 

you could associate the same call at on whatever onClick event of your app

View solution in original post

Highlighted
Established Member

Re: Binding the adf-webscript-get component into a button

Jump to solution

As Eugenio Romano‌ said you can web script on an onClick event of your app.

You can call custom web script by executeWebScript() refer this for detail:- GitHub - Alfresco/alfresco-js-api at master 

Highlighted
Active Member II

Re: Binding the adf-webscript-get component into a button

Jump to solution

one more question Eugenio Romano‌, because I'm using a webscript to create a Google Docs, is there a way to change/construct where the Google Docs is being created? Like for instance if I want to create it inside a folder? because right now it is by default getting created in the documentLibrary folder even if I try to create it somewhere else. Thanks!

Highlighted
Alfresco Employee

Re: Binding the adf-webscript-get component into a button

Jump to solution

I guess it depends from your webscript that actually I don't know wht it does inside. I guess I need more context 

Highlighted
Active Member II

Re: Binding the adf-webscript-get component into a button

Jump to solution

scriptPathDocs: string = 'googledocs/createContent?contenttype=document&parent=workspace://SpacesStore/8f2105b4-daaf-4874-9e8a-2152569d109b';

Ahh got it now, in my scriptPathDocs, it has the folder documentLibrary value by default in it. Now, how will I approach this if I want the document to be created in a specific location?

Highlighted
Alfresco Employee

Re: Binding the adf-webscript-get component into a button

Jump to solution

yes you need to change it 

Highlighted
Alfresco Employee

Re: Binding the adf-webscript-get component into a button

Jump to solution

i guess you need to pass a parameter to it but for the webbscript the ECM part of the community portal can help you better 

Highlighted
Active Member II

Re: Binding the adf-webscript-get component into a button

Jump to solution

kinda solved it by doing this by changing the scriptPathDocs, from documentLibrary folder to repository/root/Company Home folder,

scriptPathDocs: string = 'googledocs/createContent?contenttype=document&parent=workspace://SpacesStore/cd49a7d6-8e38-487f-8af4-9fed5027c8c9';

onGoogleDocsCreate() {

    this.scriptPathDocs = 'googledocs/createContent?contenttype=document&parent=workspace://SpacesStore/' + this.documentList.currentFolderId;

    this.apiService.getInstance().webScript.executeWebScript('GET', this.scripPathDocs, this.scriptArgs, this.contextRoot, this.servicePath).then((webScriptdata) => {

    this.data = webScriptdata;

    this.documentList.reload();

});

}

I am able to create a google document in any folder except in the repository/root/Company Home location. and this is the error I'm getting.

> ERROR Error: "Uncaught (in promise): Error: {

    "status" : {

    "code" : 500,

    "name" : "Internal Error",

    "description" : "An error inside the HTTP server which prevented it from fulfilling the request."

},

    "message" : "09280051 Node does not exist: workspace:\/\/SpacesStore\/-root- (status:null)",

    "exception" : "",

    "callstack" : [],

    "server" : "Enterprise v5.2.3 (r852994b1-b12) schema 10,065",

    "time" : "Oct 28, 2018 10:31:15 PM"

}