cancel
Showing results for 
Search instead for 
Did you mean: 

Property 'webScript' does not exist on type 'AlfrescoApi'

Upladder
Confirmed Champ
Confirmed Champ

I am going through the tutorial "Working with a Data Table"
https://www.alfresco.com/abn/adf/docs/tutorials/working-with-data-table/

When I am trying to run the code in "Playing with the data source" section, I get a error said

"
ERROR in app/src/app/mydatatable/mydatatable.component.ts:17:35 - error TS2339: Property 'webScript' does not exist on type 'AlfrescoApi'.

17 this.apiService.getInstance().webScript.executeWebScript(
"

How to fix it? or any materials I should read?

My mydatatable.component.ts code:

import { Component, OnInit } from '@angular/core';

import { AlfrescoApiService } from '@alfresco/adf-core';
import { ObjectDataTableAdapter, ObjectDataRow } from '@alfresco/adf-core';

@Component({
  selector: 'aca-mydatatable',
  templateUrl: './mydatatable.component.html',
  styleUrls: ['./mydatatable.component.scss']
})
export class MydatatableComponent implements OnInit {


  data = new ObjectDataTableAdapter([],[]);

  constructor(private apiService: AlfrescoApiService) {
    this.apiService.getInstance().webScript.executeWebScript(
      'GET',
      'people',
      [],
      null,
      'api/-default-/public/alfresco/versions/1',
      null
    ).then(
      (response: any) => {
        let results = [];
        for (var entry of response.list.entries) {
          results.push({
            id: entry.entry.id,
            firstName: entry.entry.firstName,
            lastName: entry.entry.lastName,
            status: 'green',
            icon: 'material-icons://accessibility'
          });
        }
        this.data.setRows(results.map(item => { return new ObjectDataRow(item); }));
      }
    );
  }

  ngOnInit(): void {
  }

  onRowClick(event: any) {
    alert('We just clicked row id: ' + event.value.obj.id);
  }

}

Thanks.

5 REPLIES 5

KarekMedAM
Star Contributor
Star Contributor

The tutorial may be out of date. I think the webscript has been deprecated from newer versions of the ADF and it is no longer available. I used EcmUserService and it worked.

hei sorry to bother can you give a example of the new solution ?

Use the EcmUserService.

  constructor(private userService:EcmUserService) { 
   
  }

getAllUsers(): void {


    this.userService.peopleApi.listPeople().then(
      (data:any) => {
        data = data.list.entries;    
      },
      (error: HttpErrorResponse) => {
      console.log (error.name + ' ' + error.message);
      });
  }

Then use data however you like to, just like any variable in angular.

Hi! Could you explain to me where you found these? The EcmUserService isn't listed verbatim in the documentation?

look at these links:

https://www.alfresco.com/abn/adf/docs/core/services/ecm-user.service/#

https://github.com/Alfresco/alfresco-ng2-components/blob/develop/lib/core/services/ecm-user.service....

and use it in this way: 

  constructor(private userService:EcmUserService) {
   
  }
//this for example will get all the users in ECM
this.userService.peopleApi.listPeople()
Getting started

Explore our Alfresco products with the links below. Use labels to filter content by product module.