• Valentina Ermilova
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
I got user Id and trying to get user. This user is exist with this Id exactly. But I get 0 rows.
 
if (Schema.sObjectType.User.fields.Email.isAccessible() &&
            Schema.sObjectType.User.fields.FirstName.isAccessible()){

            User recipient = [SELECT Email, FirstName
                               FROM User
                               WHERE Id = :recipientId];
}
This script is a part of our REST API. So it run with permissions of Site Guest User.

Where the error can be?
 
Hi,
I am trying to automatically save external pdf like this as attachment to object.
Code below solve this problem but pdf in attachment is not pdf by link. It render page without url parameters.
So instead pdf of this page (with parameters) I get pdf of this (without parameters).
 
// set URL
PageReference pdf = new PageReference('http://api.pdflayer.com/api/convert');

// set parameters
pdf.getParameters().put('access_key','5f9cb183f80d9d7a9b9fe3e848c06cf9');
pdf.getParameters().put('document_url','https%3A%2F%2Fgoogle.com');

// render PDF
Blob b = pdf.getContentAsPDF();

// create object
Test_object__c tst = new Test_object__c(Name='dTest');
insert tst;

// create attachment for object
Attachment att=new Attachment();
att.Body=b;
att.Name='Report_' + System.now().format('dd.MM.yyyy') + '.pdf';
att.parentId=tst.id;

insert att;


 
I have 2 accounts where was installed my package. I installed 1.22 version on first account and 1.26 version on second account.
Then I deprecated versions 1.23-1.25. Before this I could not install new 1.27 version on first account.
This message is appear: 
User-added image
I waiting for 1 day, but I still see this message.
Now I undeprecate versions 1.23-1.25, but still can't install new version on first account.
Also I tried to install package on new third account. I can install 1.22 version on it, but can't 1.23 and higher.
Can't find apex class with invocable method in Process Builder on production org. On develop org it works fine.
User-added image
I tryed recompile all classes, it did not help. Class successfuly pass test. Please, what can be wrong?
 
global class SearchObjectWhenCreate {

global class Request {
    @InvocableVariable
    public String objectId;
    @InvocableVariable
    public String searchType;
}

@InvocableMethod
public static void searchObject(List<Request> requests) {

    SearchButtonsController searchButtonsCtrl = new SearchButtonsController();
    List<verf__VF_Search__c> listOfSearches = new List<verf__VF_Search__c>();

    if (Schema.sObjectType.VF_Search__c.fields.Id.isAccessible()){
        listOfSearches = [SELECT Id
                        FROM verf__VF_Search__c
                        WHERE Name =: requests[0].searchType
                        LIMIT 1];
    }
    if(!listOfSearches.isEmpty()){
        searchButtonsCtrl.vf_searchId = listOfSearches[0].Id;
        searchButtonsCtrl.strObjectId = requests[0].objectId;
        searchButtonsCtrl.getObjectInfo();
        searchButtonsCtrl.isCalledFromProcessBuilder = true;
        searchButtonsCtrl.searchRequest();
        request(searchButtonsCtrl.xmlStringxmlRes, searchButtonsCtrl.vf_searchName);
    }
}

@future(callout=true)
public static void request(String xmlStringxmlRes, String searchName) {
    Http httpProtocol = new Http();
    HttpRequest request = new HttpRequest();
    HttpResponse response = new HttpResponse();
    String body = 'request=' + xmlStringxmlRes;

    String endpoint = 'https://viqzrh5hp3.execute-api.us-east-1.amazonaws.com/verified_first';
    request.setEndPoint(endpoint);
    request.setBody(body);
    request.setMethod('POST');

    try {
         if(!Test.IsRunningTest()){
            response = httpProtocol.send(request);
            parseXMLResponce(response.getBody(), searchName);
        }
    } catch(System.CalloutException e) {
    }
}

 
I got user Id and trying to get user. This user is exist with this Id exactly. But I get 0 rows.
 
if (Schema.sObjectType.User.fields.Email.isAccessible() &&
            Schema.sObjectType.User.fields.FirstName.isAccessible()){

            User recipient = [SELECT Email, FirstName
                               FROM User
                               WHERE Id = :recipientId];
}
This script is a part of our REST API. So it run with permissions of Site Guest User.

Where the error can be?
 
Can't find apex class with invocable method in Process Builder on production org. On develop org it works fine.
User-added image
I tryed recompile all classes, it did not help. Class successfuly pass test. Please, what can be wrong?
 
global class SearchObjectWhenCreate {

global class Request {
    @InvocableVariable
    public String objectId;
    @InvocableVariable
    public String searchType;
}

@InvocableMethod
public static void searchObject(List<Request> requests) {

    SearchButtonsController searchButtonsCtrl = new SearchButtonsController();
    List<verf__VF_Search__c> listOfSearches = new List<verf__VF_Search__c>();

    if (Schema.sObjectType.VF_Search__c.fields.Id.isAccessible()){
        listOfSearches = [SELECT Id
                        FROM verf__VF_Search__c
                        WHERE Name =: requests[0].searchType
                        LIMIT 1];
    }
    if(!listOfSearches.isEmpty()){
        searchButtonsCtrl.vf_searchId = listOfSearches[0].Id;
        searchButtonsCtrl.strObjectId = requests[0].objectId;
        searchButtonsCtrl.getObjectInfo();
        searchButtonsCtrl.isCalledFromProcessBuilder = true;
        searchButtonsCtrl.searchRequest();
        request(searchButtonsCtrl.xmlStringxmlRes, searchButtonsCtrl.vf_searchName);
    }
}

@future(callout=true)
public static void request(String xmlStringxmlRes, String searchName) {
    Http httpProtocol = new Http();
    HttpRequest request = new HttpRequest();
    HttpResponse response = new HttpResponse();
    String body = 'request=' + xmlStringxmlRes;

    String endpoint = 'https://viqzrh5hp3.execute-api.us-east-1.amazonaws.com/verified_first';
    request.setEndPoint(endpoint);
    request.setBody(body);
    request.setMethod('POST');

    try {
         if(!Test.IsRunningTest()){
            response = httpProtocol.send(request);
            parseXMLResponce(response.getBody(), searchName);
        }
    } catch(System.CalloutException e) {
    }
}