• DixitS
  • NEWBIE
  • 50 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 4
    Questions
  • 22
    Replies
 When I select accname and click the FIND button i need to display those name records . There is no error , but I didn't get the records. Plz check and suggest me where is the problem and also i nned to display these records in another VF page. How it is ? I think Using page reference  ri8 ?


VF code:

<apex:page controller="accountfiltercon">
    <apex:form >
        <apex:pageBlock>
          <apex:pageBlockSection title="select picklist field value">
    <apex:selectList size="1" value="{!selectedname}"> 
        <apex:selectOptions value="{!selectedaccnamefields}"/>  
    </apex:selectList>
      </apex:pageBlockSection>  
         <apex:pageBlockSection title="List of Account Records">
             <apex:pageBlockTable value="{!arecs}" var="item">
                 <apex:column value="{!item.id}"/>
                 <apex:column value="{!item.name}"/>
                 <apex:column value="{!item.billingcity}"/>
                 <apex:column value="{!item.phone}"/>
             </apex:pageBlockTable>
             <!--apex:pageBlockButtons-->
                 <apex:commandButton value="FIND" action="{!pf}"/>
             <!--/apex:pageBlockButtons-->
         </apex:pageBlockSection>   
     </apex:pageBlock>       
    </apex:form>
</apex:page>

Apex Code:

public class accountfiltercon {
    Public string selectedname{get;set;}
    public list<account> arecs{get;set;}
        Public List<Selectoption> getselectedaccnamefields(){
            List<Selectoption> pickname = new List<selectoption>();
            pickname.add(new selectOption('', '- None -'));
            for(Account acc :[SELECT id,name,phone,type,industry,billingcity FROM Account]){
            pickname.add(new selectoption(acc.id,acc.name));
            }
            return pickname; 
        }
    public void pf(){
        list<list<sobject>> lf=[find:selectedname in all fields returning account(id,name,billingcity,phone)];
    
    
    arecs=[select id,name,billingcity,phone from account where name=:selectedname];
    }
}
Code is working fine in dev org and it is getting internal server Error in another Org. Code is absolutely same in both of the org. Below is the code of VF page, as I am able to recognise in console, the code is not executing after line 16. Not sure, if this is causing any issuePrevent Creation of Function Expressions When Using $A.createComponent() or $A.createComponents() in Aura Components.  Does anyone aware of this kind of error? Thanks in advance 
<apex:page standardController="Campaign_Request_Task__c" recordSetVar="selectedTasks" extensions="PT_CloneCampaignReqTasksController">
    <apex:includeLightning />
    <head>
    <apex:slds />
    </head>
    
    <div style="padding-top: 90px; padding-bottom: 120px;padding-left:10%;padding-right:10%;background-color:#f4f6f9">  
    <div class="slds-modal__container slds-theme_default" style = "padding-top:32px;padding-right:8px;padding-left:8px;background-color:white" id="page" >   
        
    </div> 
   </div>
    <script>
    var selectedTaskRecordIds = "{!taskIds}";
    var campaignReqId = "{!campaignReqId}";
    console.log("selectedTaskRecordIds",selectedTaskRecordIds);
    console.log("campaignReq",campaignReqId);
    
    $Lightning.use("c:PT_CloneCampaignRequestTasksApp", function() {
        $Lightning.createComponent(
            "c:PT_CloneCampaignRequestTasks",
            {"selectedTaskRecordIds": selectedTaskRecordIds,
             "baseCmpReqId":campaignReqId},
            "page",
            function(cmp) {
                console.log("Component is created!");
                console.log(cmp);
            });
        
    });
    
    </script>  
    
</apex:page>

User-added image
  • February 08, 2021
  • Like
  • 0
After secure guest user record access, We are using force.com sites to access and update the account records. We using the VF page extension class(without sharing keyword) to update the account record. Does without sharing class can ignore the Secure guest user record access?
  • March 04, 2020
  • Like
  • 0
Hello All,
I have a requirement, on button click download the detail page of record as a Word doc, I wrote the below code but when file is getting downloaded cross is coming in place of image (Owner name avatar),  however, I used CSS and javascript to hide all the images from Page but it's not working . Please help. Thanks in advance
<apex:page standardController="opportunity"  contentType="application/msword#Tender_Opportunity.doc" cache="true" showHeader="false" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false">
<html xmlns:w="urn:schemas-microsoft-com:office:word">
     <head>
       <style>
       
         .labelCol {
               font-weight: bold;    
               font-family: Calibri;             
                width: 200px;
               text-align: left;

            }
             .dataCol {
                     width: 300px;
                     margin-right: 20px;
           }
           .col02 {
                     width: 300px;
                     margin-right: 20px;
           }    
           a {
                text-decoration: none;
            }   
            img[src=""] {
               display: none;
               visibility: hidden;
            } 
        </style> 
        <script>
        window.onload = function removeImg() {
          var images = document.getElementsByTagName('img');
            for(var i=0; i < images.length; i++) {
                images[i].parentNode.removeChild(images[i]);
            }
        }
        </script>
          <base href="http://blogforce9dev-developer-edition.ap1.force.com/salesforceicons"/>       
     </head>   
     <body>
         <apex:detail subject="{!opportunity.id}" relatedList="false" title="false"/>
     </body>
 </html>
</apex:page>

 
  • April 25, 2018
  • Like
  • 0
Map<String, Object> myMap = new Map<String, Object>();
myMap.put('removedPartId ', 'a0L1500000Mjavp');
Flow.Interview.FindPRC findPrcFlow= new Flow.Interview.FindPRC(myMap);
findPrcFlow.start();
  • December 23, 2016
  • Like
  • 0
Hi 

I am running this generic code which is used to return set of ID.

public statset<id>getetIdSet(sObject[] pSobjects, string pSObjField){
        set<Id> sObjIdSet = new set<Id>();
        for(sObject sObj : pSobjects){
            if(pSObjField != null){
                //split reference fields
                string[] refFields = pSObjField.split('\\.');
               
               if(refFields.size() > 1){
                 System.debug(sObj.getSObject(refFields[0]));
                    if(sObj.getSObject(refFields[0]) != null && sObj.getSObject(refFields[0]).get(refFields[1]) != null){                       
                        sObjIdSet.add(string.valueOf(sObj.getSObject(refFields[0]).get(refFields[1])));
                    }
}
return sObjIdSet;
}
getIDset(newContacts, 'reference_field__r.field__c');
System.debug( sObj.getSObject(refFields[0])); this statement is returning NULL even though there is value in both the field.

Can someone please help regarding this issue . how to access parent fields when running from child trigger context.
                   
After secure guest user record access, We are using force.com sites to access and update the account records. We using the VF page extension class(without sharing keyword) to update the account record. Does without sharing class can ignore the Secure guest user record access?
  • March 04, 2020
  • Like
  • 0
I have a VisualForce page which displays records from a filtered list view. When I preview the VF page it shows the filtered list. However, when I display that same VF page on a Sites page it reverts to an unfiltered list of all the records in the object. Here's my VF page code:

<apex:page standardController="Volunteer_Position__c" recordSetVar="positions" showHeader="false">
    <apex:pageBlock >
         <apex:pageBlockTable value="{!positions}" var="position" id="Actively_recruiting_positions__c">
              <apex:column value="{!position.Name}"/>
                          <apex:column value="{!position.Apply_form_link__c}"/>
         </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page> 

It's supposed to display only the volunteer positions to which I am actively recruiting.
Hi, 

I'm using Simple Salesforce in python to get some fields needed in our analysis; however, apart from  "Name" & "ID" , is there any other variables I can add to the following query?

sf.query("SELECT ID, Name FROM Opportunity")

I am new to Salesforce and Simple Salesforce; I wish to add a time constraint in the query above so that it only returns the recent one year's data. Is there any way to implement this?

Thanks!!
List<Consultant__c> toBeSubmittedCons = [select id,Pan_Number__c,category__c,Phone__c,Email__c,System_otp__c,owner.IT_HEAD__c,owner.NON_IT_HEAD__c from Consultant__c];

custom object : Consultant__c
custom fields in user object
1.IT_HEAD__c : lookup to user
2.NON_IT_HEAD__c :lookup to user
I have to delete the Quote if Quote_Number__c in opportunity is equal to Quote_Number__c in Quotes. Can you please provide a sample trigger for that 
I'm Logged in as a System Admin but I am not able to access Service Setup.
https://success.salesforce.com/issues_view?id=a1p3A0000001D14QAE
User-added image
Hello All,
I have a requirement, on button click download the detail page of record as a Word doc, I wrote the below code but when file is getting downloaded cross is coming in place of image (Owner name avatar),  however, I used CSS and javascript to hide all the images from Page but it's not working . Please help. Thanks in advance
<apex:page standardController="opportunity"  contentType="application/msword#Tender_Opportunity.doc" cache="true" showHeader="false" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false">
<html xmlns:w="urn:schemas-microsoft-com:office:word">
     <head>
       <style>
       
         .labelCol {
               font-weight: bold;    
               font-family: Calibri;             
                width: 200px;
               text-align: left;

            }
             .dataCol {
                     width: 300px;
                     margin-right: 20px;
           }
           .col02 {
                     width: 300px;
                     margin-right: 20px;
           }    
           a {
                text-decoration: none;
            }   
            img[src=""] {
               display: none;
               visibility: hidden;
            } 
        </style> 
        <script>
        window.onload = function removeImg() {
          var images = document.getElementsByTagName('img');
            for(var i=0; i < images.length; i++) {
                images[i].parentNode.removeChild(images[i]);
            }
        }
        </script>
          <base href="http://blogforce9dev-developer-edition.ap1.force.com/salesforceicons"/>       
     </head>   
     <body>
         <apex:detail subject="{!opportunity.id}" relatedList="false" title="false"/>
     </body>
 </html>
</apex:page>

 
  • April 25, 2018
  • Like
  • 0
Hi, 

I have one problem while trying to achieve one trailhead challenge.
I need to create a user with the User license Chatter Free, but this users license has dissapear from the drop list.
User-added image

What can I do to recover that user license?

Thanks
 
Map<String, Object> myMap = new Map<String, Object>();
myMap.put('removedPartId ', 'a0L1500000Mjavp');
Flow.Interview.FindPRC findPrcFlow= new Flow.Interview.FindPRC(myMap);
findPrcFlow.start();
  • December 23, 2016
  • Like
  • 0
 When I select accname and click the FIND button i need to display those name records . There is no error , but I didn't get the records. Plz check and suggest me where is the problem and also i nned to display these records in another VF page. How it is ? I think Using page reference  ri8 ?


VF code:

<apex:page controller="accountfiltercon">
    <apex:form >
        <apex:pageBlock>
          <apex:pageBlockSection title="select picklist field value">
    <apex:selectList size="1" value="{!selectedname}"> 
        <apex:selectOptions value="{!selectedaccnamefields}"/>  
    </apex:selectList>
      </apex:pageBlockSection>  
         <apex:pageBlockSection title="List of Account Records">
             <apex:pageBlockTable value="{!arecs}" var="item">
                 <apex:column value="{!item.id}"/>
                 <apex:column value="{!item.name}"/>
                 <apex:column value="{!item.billingcity}"/>
                 <apex:column value="{!item.phone}"/>
             </apex:pageBlockTable>
             <!--apex:pageBlockButtons-->
                 <apex:commandButton value="FIND" action="{!pf}"/>
             <!--/apex:pageBlockButtons-->
         </apex:pageBlockSection>   
     </apex:pageBlock>       
    </apex:form>
</apex:page>

Apex Code:

public class accountfiltercon {
    Public string selectedname{get;set;}
    public list<account> arecs{get;set;}
        Public List<Selectoption> getselectedaccnamefields(){
            List<Selectoption> pickname = new List<selectoption>();
            pickname.add(new selectOption('', '- None -'));
            for(Account acc :[SELECT id,name,phone,type,industry,billingcity FROM Account]){
            pickname.add(new selectoption(acc.id,acc.name));
            }
            return pickname; 
        }
    public void pf(){
        list<list<sobject>> lf=[find:selectedname in all fields returning account(id,name,billingcity,phone)];
    
    
    arecs=[select id,name,billingcity,phone from account where name=:selectedname];
    }
}

Hi there,

I've been trying to figure out a way to remove an embedded page from the "edit" view on a custom object that uses a standard record page layout - the embedded page contains information that makes sense when one is simply viewing a record (as well as interactive elements such as buttons etc), but it is undesirable in the context of editing said record as I'd rather not give users the ability to click random things while editing a record, as well as not wanting to display useless data that doesn't need to be there anyway. In Salesforce Classic it used to be the case that any embedded page will be automatically hidded from "edit" views, and it seems that the opposite is true for Lightning, with no flexibility.

The fact that the page is embedded into what is essentially a standard view (i.e. where I don't have access to its code) makes it harder and Im running out of ideas as to how I can achieve the desired result. Any advice would be much appreciated. 

Hi Everybody,
I have a problem while trying to update actorid of a ProcessInstanceWorkItem record through Apex.  As part of delegating to a new user, we need to reassign the request to a new user.  This update can be done by an administrator (System Administrator) or by a manager (who can be a normal user such as Default Employee profile user, etc).  The code is working for administrator users.  But throwing the below error.
   
Error in Saving the Record: Delegate_after_trig: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 04iT0000000LcnHIAS; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: [] Class.myClass.tstMethod: line 22, column 1 trigger.Delegate_after_trig: line 182, column 1
   
I thought if I can run the apex code as System Administrator, I may not come across the above error.  Hence I tried the below approaches.

  1. Set "Modify All" flag on the request, which starts the approval process.  This worked fine.  But this allowed the users to see other users details.  But we don't want this behavior.  Hence this option is ruled out.
  2. Created a class "without sharing" with only this method (as the documentation mentioned that the code in this class does not follow the logged in user's sharing rules and run as System Administrator)
  •             Called this method from another class.  But this threw the same error mentioned above.
  •             Called this method from a trigger.  But this threw the same error mentioned above.


Here is the code, which I am using to update the actorid.  I hardcoded some values for my testing. The query is working fine and returning the result what I am expecting.  I tried updating OriginalActorId by logging in as normal user, it is getting updated with out any errors.

 

I found some posts with this issue on this board, but did not have much details on what they did to make it work for them.  Hence I thought of seeking your help.  I greatly appreciate if someone can help me in resolving this error.

    
public without sharing class myClass{
    public static void tstMethod() {
        //Get Processinstance workitem
        List<ProcessInstanceWorkItem> piwi_to_update = new List<ProcessInstanceWorkItem>();
        List<ProcessInstanceWorkItem> piwi = [SELECT ActorId, OriginalActorId
                            FROM ProcessInstanceWorkitem
                               WHERE ProcessInstanceId in ('04gT000000070mUIAQ')
                             AND actorid != '00530000003eDDbAAM'];
        System.debug('piwi ----------> ' + piwi);
        for (integer j=0; j<piwi.size(); j++){
            System.debug('--------------->piwi[' + j + '] ------------> ' + piwi[j]);
            piwi[j].ActorId = '00530000001mxv2';
            //piwi[j].OriginalActorId = '005T0000001UydwIAC';
            piwi_to_update.add(piwi[j]);
        }
        //Update ProcessInstance work items
        system.debug('-------------->piwi_to_update = ' + piwi_to_update);
        update piwi_to_update;
    }
}

Hi,

 

I am getting the below error when i try to save my Apex Controller.

 

line -1, column -1: Dependent class is invalid and needs recompilation: <Namespace.ApexClassName>: <line No> Didn't understand relationship '<Custom Object Name>' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

 

I checked my WSDL file and could see the field in that Object.

 

Can anyone help me why is this issue being faced.

 

Regards,

OnDem

Hi,

I have a very odd problem indeed.  I am trying to build a nested Map of Contact details.  I need to loop through each Contact record, create a map with the values, Email, AccountId and ContactId and then add this to another map with a integer key.  All pretty straight forward, yet when I try and access the parent map and display the child entries I get the message 'Already Output' and when I loop through the Parent Map object values are all the same, yet when outputting the items in the map after insertion they show the expected values.

The reason I need to use a Map as opposed to a SELECT clause is that we already hold the items in memory and we're trying to limit the number of queries as we're at 11 already.

Code below:
Code:
 private static testMethod void testManualConvertLead()
 {
  Account[] createAccount = new Account[]
   {
    new Account(Name = 'TestLead1'),
    new Account(Name = 'TestLead1'),
    new Account(Name = 'TestLead1')
   };
   
  insert createAccount;

  Contact[] createContact = new Contact[]
   {
    new Contact(FirstName = 'Test', LastName = 'Last 1', Email = 'test1@bob.com', AccountId = createAccount[0].Id),
    new Contact(FirstName = 'Test', LastName = 'Last 2', Email = 'test2@bob.com', AccountId = createAccount[1].Id),
    new Contact(FirstName = 'Test', LastName = 'Last 3', Email = 'test3@bob.com', AccountId = createAccount[2].Id)
   };
   
  insert createContact; 

  Map<Integer,Map<String,String>> contactDetails = new Map<Integer,Map<String,String>>();
  Map<String,String> contactDetail = new Map<String,String>();
  system.debug(createContact.size()); 
  for(integer n = 0; n < createContact.size() ; n++)
  {
   system.debug('-');
   system.debug(createContact[n].Id);
   system.debug(createContact[n].AccountId);
   system.debug(createContact[n].Email);
   
   contactDetail.put('ContactId',createContact[n].Id);
   contactDetail.put('AccountId',createContact[n].AccountId);
   contactDetail.put('Email',createContact[n].Email);
   
   system.debug(contactDetail);   
   system.debug(n);
   
   contactDetails.put(n,contactDetail);
   system.debug(contactDetails.get(n));
   system.debug('-');
  }
  
  system.debug(contactDetails);
  
  for(integer p = 0 ; p < contactDetails.size() ; p++)
  {
   system.debug(contactDetails.get(p));
  }
 }

 

Hi All,

I am new to salesforce.

Our requirement is to update few fields from Case Object in Servicenow to Custom Object in Salesforce.

Could some one please check our requirement and suggest the ways how can we achieve it.

Thanks & Regards,
Bsin
 
  • September 04, 2019
  • Like
  • 1
best things to remember to write triggers?