How to use scriptArgs in executeWebScript?

cancel
Showing results for 
Search instead for 
Did you mean: 
d_moeyersons
Customer

How to use scriptArgs in executeWebScript?

Jump to solution

Hey,

I don't understand how to use scriptArgs in [AlfrescoApiService].getInstance().webScript.executeWebScript in ADF.

I tried several ways, even using a regular string, but none of them worked.
I solved it for now by adding the args to tthe scriptPath and it works, but I wondered if someone could explain how the scriptArgs work.

this.apiService.getInstance().webScript.executeWebScript(
  'GET',
  `api/vmm/agendastructuur/workspace/SpacesStore/${result.id}?showAgendapunten=false`,
  null,
  null,
  null,
  null
).then(
  (response: any) => {
    const convertedResponse = this.objectToObjectArray(response);
    // console.log(convertedResponse);
    this.nodes = convertedResponse;
  }
);

Thanks!

David.

1 Solution

Accepted Solutions
eugenio_romano
Alfresco Employee

Re: How to use scriptArgs in executeWebScript?

Jump to solution

Inside the project, there is an index.d.ts that should help your IDE to understand the types. Maybe your IDE is not configured in the riight way. Anyway, this the types:  :

executeWebScript(httpMethod?: string, scriptPath?: string, scriptArgs?: any, contextRoot?: string, servicePat?: string, postBody?: string): Promise<{}>;

It will compose an URL like that:

http(s)://(host)Smiley Sadport)/(contextPath)/(servicePath)/(scriptPath)?(scriptArgs)

scriptArgs is an object like that:

vat myParams = {
myUrlVar: 'value1',
myUrlVarTwo: 'value2',
};
‍‍‍‍‍‍‍‍‍

So for example, if you use it:

this.alfrescoJsApi.core.webscriptApi.executeWebScript('GET', 'mytasks', myParams, 'share', 'differentServiceSlug');

It should invoke 

http://127.0.01:8080/share/differentServiceSlug/mytasks?myUrlVar=value1&myUrlVarTwo=value2

View solution in original post

5 Replies
eugenio_romano
Alfresco Employee

Re: How to use scriptArgs in executeWebScript?

Jump to solution
d_moeyersons
Customer

Re: How to use scriptArgs in executeWebScript?

Jump to solution

Hi Eugenio,

Thanks for answering.
The first thing that I have done was looking into the official documentation, I know where I should put the different parameters, but the exact format isn't defined there.
I already tried a flat string (in the example above it would be: "showAgendapunten=false") as third parameter, but I didn't get the desired results. I also tried an object, object Array, string Array as third parameter, it all didn't work.

David.

eugenio_romano
Alfresco Employee

Re: How to use scriptArgs in executeWebScript?

Jump to solution

Inside the project, there is an index.d.ts that should help your IDE to understand the types. Maybe your IDE is not configured in the riight way. Anyway, this the types:  :

executeWebScript(httpMethod?: string, scriptPath?: string, scriptArgs?: any, contextRoot?: string, servicePat?: string, postBody?: string): Promise<{}>;

It will compose an URL like that:

http(s)://(host)Smiley Sadport)/(contextPath)/(servicePath)/(scriptPath)?(scriptArgs)

scriptArgs is an object like that:

vat myParams = {
myUrlVar: 'value1',
myUrlVarTwo: 'value2',
};
‍‍‍‍‍‍‍‍‍

So for example, if you use it:

this.alfrescoJsApi.core.webscriptApi.executeWebScript('GET', 'mytasks', myParams, 'share', 'differentServiceSlug');

It should invoke 

http://127.0.01:8080/share/differentServiceSlug/mytasks?myUrlVar=value1&myUrlVarTwo=value2
d_moeyersons
Customer

Re: How to use scriptArgs in executeWebScript?

Jump to solution

Thank you, this works.
My IDE (IntelliJ IDEA) is configured the right way to show hints, but I couldn't make out what the 'any' type stands for.

eugenio_romano
Alfresco Employee

Re: How to use scriptArgs in executeWebScript?

Jump to solution

yep maybe we have to improve that type definition, good point thanks