• Suraj Tripathi
  • SMARTIE
  • 1577 Points
  • Member since 2015
  • Salesforce Consultant
  • Cloud Analogy Softech Pvt Ltd


  • Chatter
    Feed
  • 48
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 278
    Replies
If an object has two Master Detail relatioship, how to check which one primary and which one secondary ?
Hi All,

Im trying to get the account name from a map in the example below, but get a null pointer excpetion, any idea why?

public class MainClass {
map<id, account> amap = new map<id, account>([select id, name, createdbyid from account]);
map<id,user> umap = new map<id, user>([select id, name from user]);
public void met1(){
        map<id, opportunity> omap = new map<id, opportunity>([select id, name, createdbyid, accountid from opportunity]);
         for(opportunity o : omap.values()){
                system.debug(omap.get(o.id).name); //This works find and give me the opp name
                system.debug(amap.get(o.accountid).name);   // this one dosent ??
            
         }   
    }   
}
  • December 02, 2017
  • Like
  • 0
My issue may be tied to creating the Global Action and the appearance of a recod type field.
When I take the challenge, I get the following error:
"Challenge Not yet complete... here's what's wrong: 
Could not find an Opportunity Quick Action with the Label 'New Offer' and the action type of 'Create a Record'."

User-added image

It would seem I did everything right, but I also see a Record Type field with 3 options, Products, Serivces, or Master. I set it to 'Master'. 
User-added image
I then set the Predefined Field value to Stage: 'Qualification'
User-added image
User-added image

Then set the Publisher layout.
User-added image

Am I missing something?

Thanks to anyone who can help. It would seemt the system can't find my Quick Action.
Hi, I am having issues uninstalling DreamHouse. Inadvertently installed to my org instead of Trailhead playground (don't ask - an avoidable mistake on my part, I know). I go to Set-Up, find where to uninstall packages and get an error message about Flows. I go to Flows under Set-up and nothing is there. Any thoughts? 

Screenshot of error message
Hello,

I am losing my mind trying to sort out why apex:repeat is not working on my visualforce page.
I've used apex:repeat before and never had any issue.

The VF page is loading, and the logs show that the SOQL list "repeatedList" has values.
The page loads fine, and nothing is shown in the apex:repeat section of the page.

Are there any other considerations I may be missing that will prevent apex:repeat from working?

VF Page:
<apex:repeat value="{!repeatedList}" var="a">
                <apex:outputText value="{!a.id}" />
</apex:repeat>
Controller:
public class cb_controller {
    public list<object__c> repeatedList {get; set;}
    
 public cb_controller(){
    list<object__c> repeatedList = new list<object__c>();
                
                List<object__c> soqlList = new List<object__c>([
                    SELECT id
                    FROM Object__c 
                    ]);
                
                for(Object__c x : soqlList){
                    repeatedList.add(x);
                    system.debug(x);
                }
                
}

Thanks in advance!
 
Hi,

i want test class for below wrapper class

public class Accountwrapper {
    
    // variable
    public list<acwrap> Acclist{get;set;}
     public list<Account> selectlist{get;set;}
   // Contructor 
    public Accountwrapper(){
        Acclist=new list<acwrap>();
        for(Account a:[select id,name,AccountNumber from Account]){
            Acclist.add(new acwrap(a));
        }
    }
    // Method
    public void selected(){
        selectlist=new list<Account>();
        for(acwrap a1:Acclist){
            if(a1.ischeck==true){
               selectlist.add(a1.acc) ;
            }
        }
        
    }
    public class acwrap{
        public Account acc{get;set;}
        public boolean ischeck{get;set;}
        public acwrap(Account ac){
            this.acc=ac;
            ischeck=false;
        }
    }
}
Hello! I am trying to display a list of opportunities and when i click on a row of an opportunity i get the full opportunity in apex:detail below the list.

 
<apex:page standardController="Opportunity" extensions="opportunityControllerExtension" recordSetVar="opportunities" tabstyle="opportunity" sidebar="false">
<head>
<apex:includeScript value="{!URLFOR($Resource.jQuery)}"  />
<script type="text/javascript">
    $j = jQuery.noConflict();
    function clickElem(elem){
        var row = parseInt($j(elem).find(".accId").html());
        alert(row);
        $j(elem).find("myString").value = row
;
    }
</script>
<apex:variable value="{!0}" var="index" />
</head>
  <apex:pageBlock >
    <apex:form >
      <apex:panelGrid columns="9">
        <apex:outputLabel value="View:"/>
        <apex:selectList value="{!filterId}" size="1">
          <apex:actionSupport event="onchange" rerender="list"/>
          <apex:selectOptions value="{!listviewoptions}"/>
        </apex:selectList>
      </apex:panelGrid>
      <apex:pageBlockTable value="{!opportunities}" var="a" id="list" onRowClick="clickElem(this);">
        <apex:column value="{!a.name}"/>
        <apex:column value="{!a.Created_Date__c}"/>
        <apex:column value="{!a.Underwriting_Stage__c}"/>
        <apex:column value="{!a.X0_Credit_Lines_Pre_Approval_Amount__c}"/>
        <apex:column value="{!a.Total_Paydowns__c}"/>
        <apex:column value="{!a.Term_Loan_Pre_Approval_Amount__c}"/>
        <apex:column value="{!a.Date_Signed__c}"/>
        <apex:column value="{!a.Reasoning_if_Failed_Credit__c}"/>
        <apex:column styleClass="accId">
                <apex:outputText >
                <apex:variable value="{!index + 1}" var="index" />
                {!index}
                </apex:outputText>
            </apex:column>
      </apex:pageBlockTable>
    </apex:form>
    <apex:pageBlock >
        <apex:detail subject="{!opportunities[myString]}" />
    </apex:pageBlock>
  </apex:pageBlock>
</apex:page>

Any help would be appreciated!
Thanks
Hi Gurus,

i've created a VF and Apex page to display a form on a Site that is linked to a custom object in Salesforce. After the form is completed, the user is then redirected to my website. 

However, how can I add a "Thank you, you have successfully submitted the form" page before the user is redirected to my website? 

Please if you have an idea of how this can be achieved, please let me know.



This is my visualforce page: 



<apex:page standardController="Turndown__c" sidebar="false" showHeader="true" extensions="extencntrl" >
    <apex:form >
           <apex:pageBlock title="Documented Turndowns" id="turndown_list">
                
             <apex:pageBlockSection columns="1" >
                 
                
                 <!-- to remove the header, but keep the fields' help texts -->
                 <style type="text/css">
                     .bPageHeader {display: none;}
                     </style>
              
                 
            <!-- Inputfields --> 
            <apex:inputfield value="{! Turndown__c.Account__c }"/>
            <apex:inputfield value="{! Turndown__c.Phone_Number__c }"/>
            <apex:inputfield value="{! Turndown__c.Region__c }"/>

            </apex:pageBlockSection>
            
                        <apex:pageBlockButtons >  
                                <apex:actionStatus id="go">
                                    <apex:facet name="stop">                  
                                        <apex:commandButton value="Save" action="{!Save}" status="go" disabled="false" rerender="go"/>
                                                </apex:facet>
                                                <apex:facet name="start">
                                       <apex:commandButton status="go" value="Saving..." disabled="true" />
                                    </apex:facet>
                                </apex:actionStatus>
                        </apex:pageBlockButtons>       
             
                 </apex:pageBlock>
    </apex:form>
</apex:page>





apex code:


public with sharing class extencntrl{
    
    Turndown__c turnd;
    public extencntrl(ApexPages.StandardController controller) {
        this.turnd= (Turndown__c)controller.getRecord();
    }
    
    public pageReference save()
        {
            Insert turnd; // steps to save your record.
            Pagereference pgref = New PageReference(Label.WebsiteURL);
            return pgref;
        }
}


Thank you very much!
I have the ID of contentVersion = 0697F000000lYE0
                         I want to download the file which has this ID , onclick of link
                         <apex:commandLink value="download"/>
                         what should i do to acheive above steps, please help me on this issue.
Hello All,
   i want to show data on vf in pageBlockTable format. but its not showing.
vf:
<apex:page controller="View_Order_Controller" sidebar="false">
  <apex:sectionHeader title="My Order"/>
  <apex:pageBlock >
  <apex:pageBlockSection >
  <apex:pageBlockTable value="{!finalOrder}" var="v">
  
  <apex:column value="{!v.name}" />
  <apex:column value="{!v.Contact_Name__c}" />
  <apex:column value="{!v.Delivery_Address__c }" />
        
  </apex:pageBlockTable>
  </apex:pageBlockSection>
  </apex:pageBlock>
</apex:page>

Controller:
public class View_Order_Controller {
  
Public List<EOrder__C> finalOrder{get; set;}

public pageReference viewOrder()
   {
   finalOrder=[select id,name,Contact_Name__c,Delivery_Address__c from EOrder__c where Contact_Name__c='fggffh'];
   return null;
   }
   
}
Its showing empty table
Get error on Lightning Components Basic: Challenge Not yet complete... here's what's wrong: Could not find the 'Expense__c' custom object with the correct fields.

I have checked the object and all fields are there.
 
what is difference between custom object and custom settings
public class Standardextensionclass {
    public contact con;
    public blob picture{get;set;}
    private ApexPages.StandardController st;
    public standardextensionclass(Apexpages.StandardController st){
        this.con=(contact)st.getrecord();
    }
    public pagereference savewithImage(){
        pagereference pr;
        try{
            insert con;
            if(picture !=null){
                Attachment at=new Attachment();
                at.Body=picture;
                at.name='Contact_' + con.id + '.jpg';
                at.ParentId=con.id;
                 at.ContentType = 'application/jpg';
        insert at;
     con.Picture_path__c = '/servlet/servlet.FileDownload?file='+ at.id;
                update con;
       Pr = new PageReference('/'+con.id);
       pr.setRedirect(true);
    
            } 
  
  } catch(Exception  e){
   system.debug('Error Message==>'+e);
  }
 
  return pr;
 } 

}
Error:Executing the 'searchForContacts' method failed. Either the method does not exist, is not static, or does not return the expected contacts.

Code:
public class ContactSearch {

    public static List<Contact> searchForContacts(String lastName, String mailingPostalCode){
        List<Contact> contactList=null;

        contactList=[SELECT Id,Name from Contact where (Last_Name__c=:lastName OR MailingPostalCode=:mailingPostalCode)];
      
        return contactList;
    }
}
 
hello friends 
plz help me with the code.
Based on the probability, calculate the amount for each product and display the amount.
Display the cumulative amount in Opportunity object only if the cumulative probability has crossed 50%.
Hi...
ALL
i want to delete Lead Records Based on the company name.But i am facing this Error any one can can support me.
public class DML_Delete 
{    
    
    public static void RecordsDeletefromLead (string StartText)
    {
        
        if(StartText !='Null' && StartText !='')
        {
            StartText +='%';
           Map<id,Lead>  DeleteLead =new Map<id,Lead> ([select id,Company from Lead where Company Like:StartText]);
        }
        if(!DeleteLead.isEmpty())
        {
            delete DeleteLead;
        }        
    } 
}
I am new to Salesforce, please help me. I have custom object Book__c with name and price__c fields. I need to write a trigger that restricts deletion of a book which is the costliest.
Below is my code:
Trigger Book_Del_trg on Book__c (before delete) {
    List <Book__c> bag = trigger.old;
    bag = [select id, price__c from Book__c order by price__c desc limit 1];
    for (Book__c book : bag){
        if(book.id != null){
            Book__c b = Trigger.oldMap.get(book.Id); 
            b.addError('Cannot delete costliest book');
        }  
    }
}

When I am deleting Costliest book it is working fine. But when I am trying to delete other books, it is showing following error:

There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger Book_Del_trg caused an unexpected exception, contact your administrator: Book_Del_trg: execution of BeforeDelete caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.Book_Del_trg: line 7, column 1". 

Any suggestions please? Thanks in advance.
 
I am using standard Opportunity and I am creating an Account once the Opportunity stage "Closed Won" using a trigger. But after creating the Account I want to update the Account field in the Opportunity with the newly created Account (means I want to link this Opportunity with the newly created Account). Please suggest me as soon as possible how to do this ?
(Very Urgent)
Bellow trigger I have written to create an Account once Opportunity "Closed Own"

trigger UpdateAccount on Opportunity (after insert, after update) {
    
    List <Account> acc = new List <Account>();
  
        for(Opportunity opp : Trigger.new)
        {
                if(opp.Name!=NULL && opp.AccountId!=NULL && opp.PB_Customer_Group__c=='First Time User' && opp.StageName=='Closed Won')
                {
                    Account acc1=new Account();
                    
                    acc1.Name=opp.Name;
                    
                    acc.add(acc1);
                    
                }
                
                
        }
        
        
        try {
                insert acc;
                   
            } 
            
        catch (system.Dmlexception e) {
                system.debug (e);
        }
        
  }


 
If an object has two Master Detail relatioship, how to check which one primary and which one secondary ?
how can I open my Trailhead playground?
how to get object manager tap?
Hi,

I created one visualforce page as pdf template. I added object field values and attachment links on this template. When i click on this attachment link, the attachment need to show on new tab. But now it will show on same page. Please share me if you know the solution.

Attachment Linking Code 

<apex:outputLink  value="{!URLFOR($Action.Attachment.Download,samplelink)}" >Click to show taachment</a>

Thanks,
Shalini R
Hi All,

Please let me know, Is it possible to convert picklist values into currency in formula?
Hi All,

I need to freeze row and column in page block table. (Not in  jquery data table).

Thanks
Azar
  • December 08, 2017
  • Like
  • 0
Hello, 

Can anyone tell me that why the font-size of all heading tags(i.e h1 to h6) are same in Visualforce Page?
Hi all,

I want help in acheiving this.
OnClick of submit button , check if condition is true, then display "Hello World" inside popup    and if condition is false then display "please enter a review first" inside popup.

Please help someone
i have to pass parametet with commandbutton which is outside of table.
this is my vf: 
<apex:form styleClass="myFormStyle " >
  <center>
  <!----------------pageBlock--------------------------------------->
  <apex:pageBlock title="My Bucket"  >
  
  <apex:pageMessages id="msg"> </apex:pageMessages>
  <!-------------first section-display table and take quantity from user----------------->
  <apex:pageblockSection >
  <apex:pageBlockTable value="{!itemInBucket}" var="i">
   <apex:column value="{!i.Product_Name__c}" />
   
    <apex:column value="{!i.price__c}"  />
    
    <apex:column value="{!i.Quantity__c}" headerValue="Available Quantity"/ >
    
    <apex:column headerValue="Required Quantity" >
    <apex:commandButton value="+" action="{!incrementCounter}" reRender="bucket"/>
    <apex:inputText value="{!count}" style="width: 25px !important;" styleClass="qty " id="bucket"/>
    <apex:commandButton value="-" action="{!decrementCounter}" reRender="bucket"/>
    </apex:column>
    
    <apex:Column >
    <apex:commandLink value="Place Order" action="{!placeOrderForSinglePro}" >
    <apex:param name="Pname" value="{!i.Product_Name__c}"/>
    <apex:param name="price" value="{!i.price__c}" />
     <apex:param name="quantity" value="{!i.Quantity__c}" />
    </apex:commandLink>
    </apex:column>
    
    <apex:Column >
    <apex:commandLink value="cancel" action="{!cancelOrder}" rendered="true" >
    </apex:commandLink>
    </apex:column>
    </apex:pageBlockTable> 
    </apex:pageblockSection>
    <!---------------------second section- take address and name from user--------------->
    <apex:pageBlockSection >
    <apex:inputText value="{!n}" label="Name" />
    <apex:inputTextarea title="Address" value="{!a}" label="Address"/>
    </apex:pageBlockSection>
   
   <!---------------commandButton is in pageBlock------------------------------->
   <apex:commandButton value="Place Order for All Products" action="{!placeOrderForAllPro}"/>
  </apex:pageBlock>
  </center>
  
  <apex:commandLink value="View Order" action="{!openOrderPage}"/>
  <apex:commandLink value="Previous Page" style="float:right;" action="{!redirect}"/>
  </apex:form>
</apex:page>

here i am taking quantity name and address from user and storing all that into Order__C object. now my inputFileds are in diffrent pageBlockSection and my command button is in pageBlock. so how can i insert  that  to Order__c when i click on commandButton.
apex:command button value = "Complete Regisration" keeps returning an Error page - Authorization Required You must first log in ...  What can be the issue?
We're having below markup in Lightning component.
<lightning:icon aura:id="statusIcon" iconName="action:check" size="xx-small"/>

When java-script is controller prints the page with this component, seems like it's omitting this icon.
 
window.print();


is used to print the page.

Is there a way I can get this icon on printed output? Appreciate any help. Thanks.
how to creat a  record through process builder
Hello guys
 i need a small help, if i earn 4 certifications(Admin,Advance admin,App builder,developer) in a single year, how much maintenance fee do i need to pay
 
Best Practice : When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.

User-added image


      That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it. 

Thanks #Copy_Steve Molis