• Siri Deva Singh Khalsa
  • NEWBIE
  • 10 Points
  • Member since 2018
  • Salesforce Administrator
  • Castle Group

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
Hi Folks,

I'm tyring to connect to the monday.com api, which, as far as I understand, accepts graphQL queries in JSON format (https://monday.com/developers/v2).

When I run the code below, I get a 400 'no query string was present' error.

If I run the method
req.SetHeader('Content-Type', 'application/json')

I can't even authenticate.

Any ideas?
 
public class mondayAPI{
    public static httpResponse callout(){

        String apiKey = 'mySuperSecretApiKey';
        String query = '{ "query" { "boards"(ids: 813785147)}} ';
        //instantiate httpRequest

        HttpRequest req = new HttpRequest();

        //set http method and endoint for request instance
        req.setMethod('POST');
        req.setEndpoint('https://api.monday.com/v2');

        //set body and header
        req.setHeader('Authorization', apiKey);
        req.setBody(query);

        //instantiate the http

        http h = new http();

        //make the call out using the http.send() method
        HttpResponse res = h.send(req);

        Integer statusCode = res.getStatusCode();

        String status = res.getStatus();

        String body = res.getBody();
        System.debug('Request Body: ' + req.getBody());
        System.debug(statusCode);
        System.debug(status);
        System.debug(body);

        return res;


    }
}

 
Hi All,

I'm trying to use a lightning-datatable component to pull in activity history on a lead record page. I want to see activity only WHERE WhoId = currentRecord.Id OR WhoId = currentRecord.ContactId__c

I test successfully until the point where I try to access the recordId in my controller. Apparently @auraEnabled methods cannot accesss ApexPages.StandardController objects.

How do I preselect out my ActivityHistory in the data table so that I only see records based on certain crtieria for the whoId? Any advice would be most appreciated.

html:
<template>
    <lightning-card title="Sorting Data in Lightning Datatable in LWC" icon-name="standard:lead" > <br/>
        <div style="width: auto;">
            <template if:true={data}>
                <lightning-datatable data={data}
                                     columns={columns}
                                     key-field="id"
                                     sorted-by={sortBy}
                                     sorted-direction={sortDirection}
                                     onsort={handleSortdata}
                                     hide-checkbox-column="true"></lightning-datatable>
            </template>

        </div>
    </lightning-card>
</template>
apex controller
public inherited sharing class dataTableController {
    
    @AuraEnabled(Cacheable = true)
    public static List<ActivityHistory> getActivity(){
        List<Lead> leadQueryList;  
        List<ActivityHistory> activityList = new List<ActivityHistory>(); //variable to hold the list of activitiyhistories
        
        leadQueryList = [                           //query all activity history related to the lead (return list of leads w nested ah lists)
                        SELECT  Id,
                                (SELECT
                                    Id, 
                                    Subject, 
                                    ActivityDate, 
                                    OwnerId,
                                    Activity_Type__c                                                                                                                                    
                                 FROM ActivityHistories)
                        FROM Lead
                        WHERE Id = :leadId]; 
        for (Lead ld : leadQueryList) {               //loop through lead list
            if(!ld.ActivityHistories.isEmpty()){
                for (ActivityHistory h: ld.ActivityHistories){
                    activityList.add(h);
                }
            }
        }
        return activityList;
    }
}


js
import {LightningElement, wire, track, api} from 'lwc';

// importing apex class methods
import getActivity from '@salesforce/apex/dataTableController.getActivity';

// datatable columns with row actions
const columns = [
    {
        label: 'Date',
        fieldName: 'ActivityDate',
        sortable: "true"
    }, {
        label: 'Activity Type',
        fieldName: 'Activity_Type__c',
        sortable: "true"
    }, {
        label: 'Subject',
        fieldName: 'Subject',
        sortable: "true"
    }, {
        label: 'Assigned',
        fieldName: 'OwnerId',
        sortable: "true"
    },
];

export default class DataTableWithSortingInLWC extends LightningElement { 
    // reactive variable
    @track data;
    @track columns = columns;
    @track sortBy;
    @track sortDirection;
    @api recordId;

    // retrieving the data using wire service
    @wire(getActivity)
    activities(result) {
        if (result.data) {
            this.data = result.data;
            this.error = undefined;

        } else if (result.error) {
            this.error = result.error;
            this.data = undefined;
        }
    }

    handleSortdata(event) {
        // field name
        this.sortBy = event.detail.fieldName;

        // sort direction
        this.sortDirection = event.detail.sortDirection;

        // calling sortdata function to sort the data based on direction and selected field
        this.sortData(event.detail.fieldName, event.detail.sortDirection);
    }

    sortData(fieldname, direction) {
        // serialize the data before calling sort function
        let parseData = JSON.parse(JSON.stringify(this.data));

        // Return the value stored in the field
        let keyValue = (a) => {
            return a[fieldname];
        };

        // cheking reverse direction 
        let isReverse = direction === 'asc' ? 1: -1;

        // sorting data 
        parseData.sort((x, y) => {
            x = keyValue(x) ? keyValue(x) : ''; // handling null values
            y = keyValue(y) ? keyValue(y) : '';

            // sorting values based on direction
            return isReverse * ((x > y) - (y > x));
        });

        // set the sorted data to data table data
        this.data = parseData;

    }
}




User-added image

 
Hi All,

I'm a bit new to this.

I'm coding a visualforce page using Visual Stuido Code and attempting to get it to deploy to my sandbox org.

I have authenticated the org and added 
"salesforcedx-vscode-core.push-or-deploy-on-save.enabled": true
to my project settings.json file.

However when I try to save my constructor class I get the below error. I can't seem to find anyone else having this problem when I search the forums.

Does anyone have guidance?
 User-added image
Hi Folks,

I'm tyring to connect to the monday.com api, which, as far as I understand, accepts graphQL queries in JSON format (https://monday.com/developers/v2).

When I run the code below, I get a 400 'no query string was present' error.

If I run the method
req.SetHeader('Content-Type', 'application/json')

I can't even authenticate.

Any ideas?
 
public class mondayAPI{
    public static httpResponse callout(){

        String apiKey = 'mySuperSecretApiKey';
        String query = '{ "query" { "boards"(ids: 813785147)}} ';
        //instantiate httpRequest

        HttpRequest req = new HttpRequest();

        //set http method and endoint for request instance
        req.setMethod('POST');
        req.setEndpoint('https://api.monday.com/v2');

        //set body and header
        req.setHeader('Authorization', apiKey);
        req.setBody(query);

        //instantiate the http

        http h = new http();

        //make the call out using the http.send() method
        HttpResponse res = h.send(req);

        Integer statusCode = res.getStatusCode();

        String status = res.getStatus();

        String body = res.getBody();
        System.debug('Request Body: ' + req.getBody());
        System.debug(statusCode);
        System.debug(status);
        System.debug(body);

        return res;


    }
}

 
Hi All,

I'm trying to use a lightning-datatable component to pull in activity history on a lead record page. I want to see activity only WHERE WhoId = currentRecord.Id OR WhoId = currentRecord.ContactId__c

I test successfully until the point where I try to access the recordId in my controller. Apparently @auraEnabled methods cannot accesss ApexPages.StandardController objects.

How do I preselect out my ActivityHistory in the data table so that I only see records based on certain crtieria for the whoId? Any advice would be most appreciated.

html:
<template>
    <lightning-card title="Sorting Data in Lightning Datatable in LWC" icon-name="standard:lead" > <br/>
        <div style="width: auto;">
            <template if:true={data}>
                <lightning-datatable data={data}
                                     columns={columns}
                                     key-field="id"
                                     sorted-by={sortBy}
                                     sorted-direction={sortDirection}
                                     onsort={handleSortdata}
                                     hide-checkbox-column="true"></lightning-datatable>
            </template>

        </div>
    </lightning-card>
</template>
apex controller
public inherited sharing class dataTableController {
    
    @AuraEnabled(Cacheable = true)
    public static List<ActivityHistory> getActivity(){
        List<Lead> leadQueryList;  
        List<ActivityHistory> activityList = new List<ActivityHistory>(); //variable to hold the list of activitiyhistories
        
        leadQueryList = [                           //query all activity history related to the lead (return list of leads w nested ah lists)
                        SELECT  Id,
                                (SELECT
                                    Id, 
                                    Subject, 
                                    ActivityDate, 
                                    OwnerId,
                                    Activity_Type__c                                                                                                                                    
                                 FROM ActivityHistories)
                        FROM Lead
                        WHERE Id = :leadId]; 
        for (Lead ld : leadQueryList) {               //loop through lead list
            if(!ld.ActivityHistories.isEmpty()){
                for (ActivityHistory h: ld.ActivityHistories){
                    activityList.add(h);
                }
            }
        }
        return activityList;
    }
}


js
import {LightningElement, wire, track, api} from 'lwc';

// importing apex class methods
import getActivity from '@salesforce/apex/dataTableController.getActivity';

// datatable columns with row actions
const columns = [
    {
        label: 'Date',
        fieldName: 'ActivityDate',
        sortable: "true"
    }, {
        label: 'Activity Type',
        fieldName: 'Activity_Type__c',
        sortable: "true"
    }, {
        label: 'Subject',
        fieldName: 'Subject',
        sortable: "true"
    }, {
        label: 'Assigned',
        fieldName: 'OwnerId',
        sortable: "true"
    },
];

export default class DataTableWithSortingInLWC extends LightningElement { 
    // reactive variable
    @track data;
    @track columns = columns;
    @track sortBy;
    @track sortDirection;
    @api recordId;

    // retrieving the data using wire service
    @wire(getActivity)
    activities(result) {
        if (result.data) {
            this.data = result.data;
            this.error = undefined;

        } else if (result.error) {
            this.error = result.error;
            this.data = undefined;
        }
    }

    handleSortdata(event) {
        // field name
        this.sortBy = event.detail.fieldName;

        // sort direction
        this.sortDirection = event.detail.sortDirection;

        // calling sortdata function to sort the data based on direction and selected field
        this.sortData(event.detail.fieldName, event.detail.sortDirection);
    }

    sortData(fieldname, direction) {
        // serialize the data before calling sort function
        let parseData = JSON.parse(JSON.stringify(this.data));

        // Return the value stored in the field
        let keyValue = (a) => {
            return a[fieldname];
        };

        // cheking reverse direction 
        let isReverse = direction === 'asc' ? 1: -1;

        // sorting data 
        parseData.sort((x, y) => {
            x = keyValue(x) ? keyValue(x) : ''; // handling null values
            y = keyValue(y) ? keyValue(y) : '';

            // sorting values based on direction
            return isReverse * ((x > y) - (y > x));
        });

        // set the sorted data to data table data
        this.data = parseData;

    }
}




User-added image

 
I'm trying to get through the service cloud superbadge, and challenge 3 is giving me this issue

"We can't find Entitlements on the Case Lightning Page. Ensure Entitlements are visible on Cases in Lightning."

I've got entitlements on the case record page, via the parent account, and I've got entitlements history via the parent Entitlement Name.. 

What is it actually looking for?