• Rakesh K 60
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 2
    Replies
I'm writing an Apex Invocable method that should return a wrapper class data and my code is as below.
@InvocableMethod
    global static List<List<prodWrap>> getProducts() 
    {
        List<List<prodWrap>> wrapper = new List<List<prodWrap>>();
         List<Product2> productsAvailable = [SELECT Id, Name FROM Product2 WHERE Name LIKE '%Hoses%'];
        List<prodWrap> responseList=new List<prodWrap>();
        for (Product2 products: productsAvailable ){       
            PricebookEntry pe=[SELECT Id, Pricebook2Id, Product2.Name, UnitPrice FROM PricebookEntry where Product2Id=:products.Id order by createddate desc LIMIT 1];
            responseList.add(new prodWrap(products.Name, Integer.valueOf(pe.UnitPrice)));
        }
        wrapper.add(responseList);
        return wrapper;
    }
    
    public class prodWrap {
        public String name {get; set;}
        public Integer price {get; set;}
        public prodWrap(String name, Integer price){
            this.name = name;
            this.price = price;
        }
    }


the error that I get is InvocableMethod methods do not support return type of List<List<ClassName.prodWrap>>. Please let me know where am I going wrong and how can I fix this.
Thanks
Hello Experts,

I need a quick confirmation with my code. The requirement is like this.

 1. When I delete/create/update an Account
 2. There is this object called track
 3. I want this object to have the Account Name with type.
trigger TrackMethod on Account (before delete) {
        List<Track__c> tList = new List<Track__c>();
        if(Trigger.isBefore)
        { 
            if(Trigger.isDelete){
                for (Account m : [SELECT Id, Name FROM Account where Id IN :Trigger.old]) {
                    Track__c t = new Track__c();
                    t.Name=m.name;
                    t.action__c='Deleted';
                    t.type__c='Account';
                    tList.add(t);
                }
            }
        }
    else if(Trigger.isAfter) {
            for(Account m:trigger.New){
                Track__c t = new Track__c();
                t.Name=m.name;
                if(Trigger.isInsert){
                    t.action='Created';
                } else if(Trigger.isUpdate){
                    t.action='Updated';
                }
                t.type__c='Method';
                tList.add(t);
            }
        }
        insert tList;
    }
Please let me know if my code is correct.

Thanks
Hi,

I'm writing a code where I need to query the product's object, get the product image URL, convert the Image in the URL to a base64 string for my other REST input. Here is the code that I'm using.

 
String url='https://myOrg.demo.my.salesforce.com/servlet/servlet.FileDownload?file=0152w000001Jex4';
HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('GET');
Http binding = new Http();
HttpResponse res = binding.send(req);
Blob image = res.getBodyAsBlob();
String encRes=EncodingUtil.base64Encode(image);

for (Integer i = 0; i < encRes.length(); i=i+300) {
    Integer iEffectiveEnd = (i+300 > (encRes.length()-1) ? encRes.length()-1 : i+300);
    System.debug(encRes.substring(i,iEffectiveEnd));
}

The output that I get is as below.
User-added image

when I downloaded the same image and uploaded it online to get the base64 I get it as below. (cropped the bottom part of the output.).

User-added image

I'm unable to understand why it is printing Li4U strings at the end.
Where am I going wrong in my code and how can I fix this.

Thanks
 
Hi,

I'm trying to create a VF page that will listdown all the Tasks related to current Account and here is my VF code.
 
<apex:page standardController="Account" extensions="MyCustomController"  >
    <apex:form >
        <apex:pageBlock id="pb">
            <apex:pageBlockTable value="{!TaskList}" var="d">
                <apex:column headerValue="Subject">   
                    <apex:outputField value="{!d.Subject}">  
                    </apex:outputField> </apex:column>
            </apex:pageBlockTable>
        </apex:pageblock>
    </apex:form>
</apex:page>

And my Controller is as below.
 
public class MyCustomController {
    Public List<SObject> TaskList{get;set;}
    String currentRecordId ; 
    public MyCustomController(ApexPages.StandardController controller) {
        TaskList= new List<SObject>();
        currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
        System.debug(currentRecordId);
        List<Contact> cts = [Select Id, Name from Contact where AccountId=:currentRecordId];
        List<sObject> events = new List<sObject>();
        for(Contact c: cts){
            List<Task> tskL = [Select Id, Subject from Task where whoId=:c.Id order by ActivityDate desc];
            for(Task t: tskl){
                events.add(t); 
            }
            
            List<Event> evtL = [Select Id, Subject from Event where whoId=:c.Id order by ActivityDate desc];
            for(Event e: evtL){
                events.add(e); 
            }
        }
        
        TaskList = events;
        System.debug(TaskList);
    }
    
}

When I run this, I get the error as below.

User-added imageCan someone please let me know where I went wrong?
And I apologise if there are is any silly mistake. I'm new to VF, U started my journey with Lightning.

Thanks
Hi,

I'm writing an Apex class to retrieve the Activity History and in the result there is No WhoId, but able to see WhatID. My Apex API Version is 49(Also tried with 48 resulting the same). Here is my Code.
 
Map<String, List<sObject>> finList = new Map<String, List<sObject>>();
Account acc = [SELECT Id, Name,
               (SELECT Id, Subject, ActivityDate, WhatId, What.Name, WhoId, Who.Name, ActivitySubType FROM OpenActivities order by ActivityDate desc)
              FROM Account WHERE Id = '0012x000004g9gSAAQ'];
finList.put('actCur', acc.OpenActivities);
System.debug(finList.get('actCur'));

When I run this, here is my Sample Output.

User-added image
When I tried the Same in QueryEditor, In the output, WhoId is Shown as null. (to be simple, I got rid of the unnecessary fields).

here is my SOQL
SELECT Id, (SELECT Id, WhatId, WhoId FROM OpenActivities order by ActivityDate desc) FROM Account WHERE Id = '0012x000004g9gSAAQ'
And here is the output.

User-added image
Finally, I ran the query on the object(Task in current case) with the ID that is returned by OpenActivities, To my Surprise I'm able to see the result there. Here is my final SOQL.
 
Select WhoId, Who.Name from Task where ID='00T2x000006jnJJEAY'

And here is my output.

User-added imageI'm a bit confused about where am I going wrong. I'm running as System Admin. Please let me know how can I fix this.

Thanks

Hi there,

can we write a trigger on an event created using lightning Sync. 

here is my requirement.

  • create a calendar event in google calendar.
  • when that event is available I Salesforce, I want to write a trigger that will create a task.
currently my setup is working fine. I'm able to create even in GCal and see it in Salesforce events. But the url is long alpha numerically character. I'm unable to understand how to write a trigger on it. Also when I queried the event object using 
Select Id, subject from Event
The gCal event is not shown up. Also tried querying the ActivityHistory object, even that's negative. I'm able to see only the events created from platform. Please let me know if this is a product limitation or of any blind spot that I'm missing.

Thanks
 

 

Hi,

I'm trying to interact with LiveAgent using Javascript(node.js) and LiveAgent Rest APIs. I've gone through the documentation of it. Here one help I need is, how can I fire an event when the agent sends the message to user/client? In the documentation It appeared mostly Inbound, but how can I make it outbound even. 

Thanks
Hi,

I'm writing a code where I need to query the product's object, get the product image URL, convert the Image in the URL to a base64 string for my other REST input. Here is the code that I'm using.

 
String url='https://myOrg.demo.my.salesforce.com/servlet/servlet.FileDownload?file=0152w000001Jex4';
HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('GET');
Http binding = new Http();
HttpResponse res = binding.send(req);
Blob image = res.getBodyAsBlob();
String encRes=EncodingUtil.base64Encode(image);

for (Integer i = 0; i < encRes.length(); i=i+300) {
    Integer iEffectiveEnd = (i+300 > (encRes.length()-1) ? encRes.length()-1 : i+300);
    System.debug(encRes.substring(i,iEffectiveEnd));
}

The output that I get is as below.
User-added image

when I downloaded the same image and uploaded it online to get the base64 I get it as below. (cropped the bottom part of the output.).

User-added image

I'm unable to understand why it is printing Li4U strings at the end.
Where am I going wrong in my code and how can I fix this.

Thanks
 

Hi there,

can we write a trigger on an event created using lightning Sync. 

here is my requirement.

  • create a calendar event in google calendar.
  • when that event is available I Salesforce, I want to write a trigger that will create a task.
currently my setup is working fine. I'm able to create even in GCal and see it in Salesforce events. But the url is long alpha numerically character. I'm unable to understand how to write a trigger on it. Also when I queried the event object using 
Select Id, subject from Event
The gCal event is not shown up. Also tried querying the ActivityHistory object, even that's negative. I'm able to see only the events created from platform. Please let me know if this is a product limitation or of any blind spot that I'm missing.

Thanks