• Sebastien Plante
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies

I got an external website in PHP where I authenticate the users from Salesforce and I want to see what Permissions Set he got.

I can get information of the users from 

/services/data/v49.0/sobjects/User/<userid> 

but I can't find how to get the "permission set assignment". Is there any endpoint for that?

Thanks !

I got this simple code 
 
public class AccountShipTo {

    public Account originalAccount{get; set;}
    public list<Account> accnt {get;set;}

    public AccountShipTo (ApexPages.StandardController controller) {
        originalAccount = [SELECT Id, ParentId FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
        
        accnt = new list<Account>();
        accnt = [SELECT Id, Name, ShippingStreet,ShippingCity,ShippingState,ShippingCountry,ShippingPostalCode FROM Account WHERE ParentId = :originalAccount.Id AND ShippingStreet<>''];
    }

}

and I want to make a test class
 
@isTest(seealldata=true)
public class AccountShipToTest {

    @isTest
    public static void testAccountShipTo(){
        
        Account originalAccount = [Select Id from Account limit 1];
        
        list<Account> accnt = [SELECT Id, Name, ShippingStreet,ShippingCity,ShippingState,ShippingCountry,ShippingPostalCode FROM Account WHERE ParentId = :originalAccount.Id AND ShippingStreet<>''];
    }
}


but I got 0% coverage... what do I miss?

 

Sorry, pretty new in this! :(

I'm trying to display the last entry of a custom related list (BPG) from Account.

I'm using this
 
public class BGP_ControllerExtension {

    public String currentRecordId {get;set;}
    
    public BGP_ControllerExtension(ApexPages.StandardController controller) {
        currentRecordId = ApexPages.CurrentPage().getparameters().get('id');
    }

    public Business_Generator_Profile__c      BGPList {
        get {
           if ( BGPList == null ) {
          
                Business_Generator_Profile__c[] BGPList =
                [   SELECT  Name, Dealer__c, Account__r.Id
                    FROM    Business_Generator_Profile__c
                    WHERE Account__r.Id = :currentRecordId
                    ORDER BY CreatedDate DESC
                    LIMIT 1
                ];
            }          
            
           return BGPList;
           
        }
        private set;
    }

}

and the "sample" VF page (I will complete it when fixed! :P)
<apex:page standardController="Account"  extensions="BGP_ControllerExtension" showHeader="false">
  
  <apex:pageBlock>
    <apex:PageBlockSection title="Business Generator Profile ({!BGPList.Name})">
        <apex:outputField value="{!BGPList.Dealer__c}"/>
    </apex:PageBlockSection>
  </apex:pageBlock>
    
    
</apex:page>
and it's working fine, except for one thing... When there's nothing on the related list, It display "Content cannot be displayed: List has no rows for assignment to SObject". I wish to change that to a custom message, simply "No BGP entered or something like this".

I've been trying many things found on the internet... but I can't seems to find the best way for doing it.

Using a list seems to be the "best idea", but I never manged to get anything on the VF page... I'm lost! :'(
 

I got an external website in PHP where I authenticate the users from Salesforce and I want to see what Permissions Set he got.

I can get information of the users from 

/services/data/v49.0/sobjects/User/<userid> 

but I can't find how to get the "permission set assignment". Is there any endpoint for that?

Thanks !

I got this simple code 
 
public class AccountShipTo {

    public Account originalAccount{get; set;}
    public list<Account> accnt {get;set;}

    public AccountShipTo (ApexPages.StandardController controller) {
        originalAccount = [SELECT Id, ParentId FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
        
        accnt = new list<Account>();
        accnt = [SELECT Id, Name, ShippingStreet,ShippingCity,ShippingState,ShippingCountry,ShippingPostalCode FROM Account WHERE ParentId = :originalAccount.Id AND ShippingStreet<>''];
    }

}

and I want to make a test class
 
@isTest(seealldata=true)
public class AccountShipToTest {

    @isTest
    public static void testAccountShipTo(){
        
        Account originalAccount = [Select Id from Account limit 1];
        
        list<Account> accnt = [SELECT Id, Name, ShippingStreet,ShippingCity,ShippingState,ShippingCountry,ShippingPostalCode FROM Account WHERE ParentId = :originalAccount.Id AND ShippingStreet<>''];
    }
}


but I got 0% coverage... what do I miss?

 

Sorry, pretty new in this! :(

I'm trying to display the last entry of a custom related list (BPG) from Account.

I'm using this
 
public class BGP_ControllerExtension {

    public String currentRecordId {get;set;}
    
    public BGP_ControllerExtension(ApexPages.StandardController controller) {
        currentRecordId = ApexPages.CurrentPage().getparameters().get('id');
    }

    public Business_Generator_Profile__c      BGPList {
        get {
           if ( BGPList == null ) {
          
                Business_Generator_Profile__c[] BGPList =
                [   SELECT  Name, Dealer__c, Account__r.Id
                    FROM    Business_Generator_Profile__c
                    WHERE Account__r.Id = :currentRecordId
                    ORDER BY CreatedDate DESC
                    LIMIT 1
                ];
            }          
            
           return BGPList;
           
        }
        private set;
    }

}

and the "sample" VF page (I will complete it when fixed! :P)
<apex:page standardController="Account"  extensions="BGP_ControllerExtension" showHeader="false">
  
  <apex:pageBlock>
    <apex:PageBlockSection title="Business Generator Profile ({!BGPList.Name})">
        <apex:outputField value="{!BGPList.Dealer__c}"/>
    </apex:PageBlockSection>
  </apex:pageBlock>
    
    
</apex:page>
and it's working fine, except for one thing... When there's nothing on the related list, It display "Content cannot be displayed: List has no rows for assignment to SObject". I wish to change that to a custom message, simply "No BGP entered or something like this".

I've been trying many things found on the internet... but I can't seems to find the best way for doing it.

Using a list seems to be the "best idea", but I never manged to get anything on the VF page... I'm lost! :'(