How to Display Archived Data in Experience Cloud

    Background

    Users who have access to the Archive Widget also have access to all the archived data. Archive does not follow the Salesforce Data Security Model.

     

    How to display Archive Widget on Community?

    In order to achieve this, Archive has an option to use the Data Query SDK.
    To display in the community, the customer's dev team needs to develop a component that can present the JSON results of the SDK Data Query.

     

    Example Use Case

    The customer is using Customer Community and would like to present archived tasks that are marked as external to his customers.
    In this case, Task, a standard object, has a standard field that marks these specific external tasks: IsVisibleInSelfService.

    To solve this use case, you can create the following Data Query SDK:

    // Define the query on Task
    string objectName = ‘Task’;
    list<OB_Archiver.SearchFilter> request = new list<OB_Archiver.SearchFilter>();
    OB_Archiver.SearchFilter filter1 = new OB_Archiver.SearchFilter(IsVisibleInSelfService, ‘true’);
    request.add(filter1);
     
    // Recommended - define date range, last 90 days
    OB_Archiver.DateRange range = new OB_Archiver.dateRange('CreatedDate',
    system.today()-90,system.today());
     
    list<string> fields = new list<string>{'Name', 'Id', 'Subject', 'Status'};
       
    OB_Archiver.ArchiverAccessorResponse res =
    OB_Archiver.ArchiverAccessor.performArchiverGlobalSearch(objectName, request, fields, range);
     
    // Check success
    if(res.getStatusCode() == 200){   
     
        // debug - optional
    system.debug('code: ' + res.getStatuscode());   
     
    OB_Archiver.ArchiverAccessorSearchResponse searchResponse = res.getSearchResponseMap();   
     
        // debug - optional
    system.debug('count: '+ searchResponse.totalResultCount);   
    system.debug('scrollid:'+ searchResponse.scrollId);   
    system.debug('list size:'+ searchResponse.records.size());   
    string scrollId = searchResponse.scrollId;   
    integer page = 1;       
    while(scrollId != '-1'){       
    page++;       
    OB_Archiver.ArchiverAccessorResponse secondPage =
    OB_Archiver.ArchiverAccessor.getNextPage(searchResponse.scrollId);         
    if(secondPage.getStatusCode() == 200){           
    OB_Archiver.ArchiverAccessorSearchResponse searchResponse2 =
    secondPage.getSearchResponseMap();      
    scrollId = searchResponse2.scrollId;
    system.debug('count: '+ searchResponse2.totalResultCount);       
    system.debug('scrollid:'+ searchResponse2.scrollId);       
    system.debug('list size:'+ searchResponse2.records.size());           
    system.debug('page number: '+ page);
    }        else{           
    system.debug('response is != 200: '+ secondPage.getStatusCode());           
    system.debug('body: '+ secondPage.getBody());           
    break;
    }            }}
    else{       
    system.debug('status code erorr|: '+ res.getStatusCode());       
    system.debug('status code message|: '+ res.getErrorMessage());    }


     
    This code will return a JSON with the results of the Tasks that are visible externally.

     

    « Previous ArticleNext Article »


    Contact Us

    Sometimes you just want to talk to someone. Our customer support team is available by phone:
    Request a Technical Support Call Back