• sslodhi87
  • NEWBIE
  • 195 Points
  • Member since 2014

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 84
    Replies
I have a problem where on a custom object the cancel button takes you back to the incorrect record.

To get this I have a related list within a ticket and I press New which takes me in from a reference 00012 I then press cancel and it will take me back to a reference 00001. Is there a way of making the cancel button take you back to the correct ticket.

The buttons I am using is a custom button so it populates some fields automatically.
Hi All

We are trying to fetch contacts along with their activities.
Is there a way to fetch it in one api call (or using single soql query)? We know the way to fetch in two api calls (ie first fetch contact and then fetch activity based on whoid). I need  some way to join both objects.

Please help me out with this.

Regards
Ankit
I want know how to get indexes of checkboxes and remove them from list at a time but not by iterating. How to do this? plz someone help me...
Here are my apex class and vf page:
Class:
public class DeletingCheckedRowsController {
        public List<WrapperClass> listWrapper {get;set;}
        public list<integer> temp{get;set;}
        public Boolean allchecked {get;set;}
        public DeletingCheckedRowsController() {
            listWrapper = new List<WrapperClass>();
            List<contact> contactList = [SELECT Id, firstName, lastname, Email, Phone FROM contact];
            if(contactList.size() > 0) {
                for(contact con : contactList) {
                    listWrapper.add(new WrapperClass(con));
                }
            }
        }
        
        public class WrapperClass {
            public Boolean checked {get;set;}
            public contact con {get;set;}
            public WrapperClass(contact con) {
                this.con = con;
            }
        }
        
        public void del() {
            integer count=0;
            temp=new list<integer>();
            List<contact> listconForDel = new List<contact>();
            List<WrapperClass> listTempWrapper = new List<WrapperClass>();
            for(WrapperClass w : listWrapper) {
                count++;
                if(w.checked) {
                    if(w.con.id==null)
                    {
                       temp.add(count-1);
                    }
                    else
                    listconForDel.add(w.con);
                }
                else {
                    listTempWrapper.add(w);
                }
            }
            
            if(temp.size()>0){
                for(integer i=temp.size();i>0;i--)
                {
                    listWrapper.remove(temp[i-1]);
                }
            }
            
            if(listconForDel.size() > 0) {
                delete listconForDel;
                listWrapper = listTempWrapper;
            }
        }
        
        public void selectAll() {
            if(allchecked) {
                for(WrapperClass w : listWrapper) {
                    w.checked = true;
                }
            } else {
                for(WrapperClass w : listWrapper) {
                    w.checked = false;
                }
            }
        }
        
        public void AddRow()
        {
            contact c = new contact();
            listWrapper.add(new WrapperClass(c));
        }
        
        public void insertnewrows()
        {
            list<contact> conts=new list<contact>();
            for(wrapperclass wrap:listwrapper){
                if(wrap.checked)
                conts.add(wrap.con);
            }
            upsert conts;
        }
    }


vf page:
<apex:page controller="DeletingCheckedRowsController">
<apex:pagemessages />
    <apex:form >
        <apex:pageBlock id="pb">
           <apex:pageBlockTable value="{!listWrapper}" var="w" id="pbt">
               <apex:column > 
                   <apex:facet name="header">
                       <apex:inputCheckbox value="{!allchecked}">
                           <apex:actionSupport reRender="pb" action="{!selectAll}" event="onchange"/>
                       </apex:inputCheckbox>
                   </apex:facet>
                   <apex:inputCheckbox value="{!w.checked}"/>
               </apex:column>
               <apex:column headerValue="Contact First Name">
                    <apex:inputfield value="{!w.con.firstName}"/>
                </apex:column>
                <apex:column headerValue="Contact Last Name">
                    <apex:inputfield value="{!w.con.lastName}"/>
                </apex:column>
               <apex:column headerValue="Contact Email">
                    <apex:inputfield value="{!w.con.email}"/>
                </apex:column>
               <apex:column headerValue="Contact Phone Number">
                    <apex:inputfield value="{!w.con.phone}"/>
                </apex:column>
            </apex:pageBlockTable> 
            <br/><apex:commandLink value="Add Row" action="{!Addrow}" reRender="pbt"/>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save Selected rows" action="{!insertnewrows}" reRender="pbt"/>
                <apex:commandButton value="Delete Selected" action="{!del}" reRender="pbt"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
Hi have an parent object project and child object project schedule . When the assigned to is changed to other user email needs to be sent for that i have written trigger below is the bit of that code. Now i want to pull the field values from project ,the trigger is written on project schedule.
When i try to pull the values i am getting null eg:Project:'+ PSOne.Project__r.Name ='null '
Can anyone help me on this please?

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                    User current_user=[SELECT Email FROM User WHERE Id= :UserInfo.getUserId()] ;
                    String emailfromAddr = current_user.Email;
                    String emailtoAddr = PSOne.Assigned_To_User__c;
                    list<string> listmail= new list<string>();
                    listmail.add(emailfromaddr);
                    listmail.add(emailtoaddr);
                    mail.setToAddresses(listmail);
                    mail.setSubject(PSOne.Phase__c+' record is assigned to you  ' + PsOne.Name);  
                    mail.setPlainTextBody('To:'+ emailtoAddr +  '\n has made an change the following Task:'+  
                    '\n Subject:'+ PsOne.Phase__c+ '\n Project:'+ PSOne.Project__r.Name +'\n Due Date:'+PSOne.Project__r.Due_Date__c+'\n                                Priority:'+ PSOne.Project__r.Priority__c+
                    '\n For more details click the link below:{0}' );
                    system.debug('33333333'+ PsOne.Project__r);
                    Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
Hi Team,

I need help in auto scroll in visualforce page. Actually i have tried like this http://jsfiddle.net/e8oxc71r/2/. But it didn't work properly.

<apex:page >
      <apex:form >
          <div id="box" class="timeline container" style="overflow:scroll; width:100%; height:300px;">
          Bacon ipsum dolor amet flank sausage salami, ball tip tail shoulder capicola pork loin chicken bacon cupim chuck andouille filet mignon. Frankfurter tongue doner boudin swine tenderloin, ground round leberkas hamburger beef strip steak cow jowl. Fatback salami tri-tip, pastrami cow short loin strip steak jerky. Jerky pancetta ribeye ball tip drumstick capicola bresaola boudin sirloin shank swine ham hock turducken. Strip steak pork chop turkey meatball pancetta pork shankle sirloin meatloaf pork loin cupim biltong. Picanha t-bone ham beef ribs, salami short loin pork jowl tongue ham hock boudin. Shoulder cupim shankle short ribs, bresaola capicola sirloin. Hamburger turkey turducken strip steak brisket kielbasa chicken pig ham hock. Pork salami doner short ribs landjaeger brisket capicola sausage pastrami corned beef tenderloin. Corned beef kevin bresaola pork tongue. Strip steak ribeye tenderloin leberkas brisket tongue hamburger cow andouille salami flank. Tenderloin pig kielbasa shoulder, pork corned beef bresaola chuck fatback. Doner tail meatball meatloaf corned beef. Sausage t-bone biltong chuck drumstick tail tenderloin cow. Hamburger alcatra strip steak jerky ham turducken drumstick meatball venison ball tip ribeye pastrami picanha jowl. Short ribs chuck filet mignon ham hock short loin tongue jowl, ball tip pork loin turkey strip steak swine corned beef venison tail. Chicken tri-tip ribeye, turducken beef ribs pork belly rump sirloin. Tenderloin strip steak swine sirloin turducken tongue pork loin kevin beef frankfurter kielbasa filet mignon jerky t-bone spare ribs. Shoulder pork belly frankfurter shank prosciutto fatback pig ball tip rump jerky landjaeger ribeye t-bone tongue. Corned beef andouille chicken, kevin t-bone turducken ribeye short ribs biltong tongue tri-tip drumstick leberkas sirloin cupim. Turducken short ribs boudin, cupim kevin short loin corned beef shankle sirloin ham hock salami. Pork belly chuck corned beef, andouille tri-tip bacon capicola short ribs shoulder short loin frankfurter alcatra tail t-bone ball tip. Chicken jowl spare ribs strip steak, t-bone pancetta turducken cupim doner cow ball tip boudin ham fatback. Strip steak shankle ground round kevin, swine pastrami landjaeger alcatra. Andouille salami pork loin flank pork chop, biltong short loin chicken kielbasa turducken. Pork jowl kielbasa tail. Turkey flank shank, rump venison meatloaf swine short ribs porchetta sausage. Chuck tongue corned beef chicken short ribs. Meatball flank alcatra, kielbasa jowl cow meatloaf corned beef shankle turducken brisket doner turkey. Turducken landjaeger boudin filet mignon fatback hamburger. Swine rump turducken ham hock, pork chop leberkas frankfurter short ribs fatback porchetta ground round.
          </div>
          
          

<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">
//<![CDATA[
$(window).on('load', function() {
// global level variables.
var isPaused = false;
var direction = 1;
var element = $('#box');

// interval for scroll.
setInterval(function () {
    if (!isPaused) {
        var pos = element.scrollTop();
        var offset = 1 * direction;
        element.scrollTop(pos + offset);

        // Change the scroll direction when hit an end.
        if ((element[0].scrollHeight - element.scrollTop() == element.outerHeight()) || (element.scrollTop() <= 0)) {
            direction *= -1;
        }
    }

}, 100);

$('#box').hover(

function () {
    isPaused = true;
}, function () {
    isPaused = false;
});
});//]]> 

</script>
         
      </apex:form>
</apex:page>

Please help me in this.

Thanks in advance.
Padmasree.

 
Hi
I have the code working for preventing parent record deletion if related child record exists.
what I want to know is if a List object is present inside a loop will it hit governor limits?
public class preventaccountdeletion
{
   public void prevent_account_delete(list<Account> acc)
   {
       for(Account a:acc)
       {
          List<Contact> con=[select AccountID from Contact where AccountID=:a.ID];
          
          List<Opportunity> op=[select AccountID from Opportunity where AccountID=:a.ID];
          
          if ((con.size() > 0) || (op.size() > 0))
             a.addError('Cannot Delete Account Because It Has Related Contacts And Opportunities');
       }
   }
}

trigger trg_preventaccountdelete on Account (before delete)
{
   if (trigger.isDelete)
   {
     preventaccountdeletion p=new preventaccountdeletion();
     p.prevent_account_delete(Trigger.old);
   }
}


Thanks
pooja
Hi,

I am new to Salesforce. I need to write a trigger to show an error messages by comparing old values. Pls. see below detailed.

I have a junction object 'Related Products' which has master detail relationship with 'Contact' and have a lookup relationship with 'Product'. And I have added a related list of 'Related Products' in Contact detail page where user can create new Related Product from the Contact and can add multiple Products to it.

Now my requirment is "if any user selects a product which is already selected to that contact should through error".
For example, I have contact called "Test Contact111", In it I have created one Related Product "RP-0001" and selected a Product called "Prod111", It will get to save and will show in the Contact's detail page under 'Related Products' section.
Again from the same Contact I will create another Related Product "RP-0002" and again will select the Same Product "Prod111", now the trigger need to throw an error states "Prod111 is already selected"

Pls. help me on this.

Thanks in Advance :).
Hi Guys,

I am facing following issues while doing integration with Stripe in salesforce:

1. Not able to create more than one subscription for one customer
2. How to set the start and end date of subscription.
3. How to apply the coupon or discount on subscription.

Please help me on this

Thanks
How I can merge two account using custom visualforce page?
Hi,

I am using force:inputField in my lightning component. It is displaying all fields types including lookup if component is opened from Lightning component tabs.

But if the same component is used in VF includeLightning, it is not displaying Lookup fields.

Can any one help me in this?

Thanks

Hello,

I have a VisualForce page with the select element:

<apex:selectList value="{!StyleGuide}" size="1" styleClass="SlectBox" id="styleguideSelect">
  <apex:selectOptions value="{!StyleGuideOptions}"/>
  <apex:actionSupport event="onchange" onComplete="resetItems()" rerender="dropdownpanel, guidelines, imagespanel, result-count" action="{!doSearch}"/>
</apex:selectList>

Here is a compiled HTML:
 
<select id="j_id0:j_id60:dropdownpanel:generationTypes" name="j_id0:j_id60:dropdownpanel:generationTypes" class="SlectBox " size="1" onchange="A4J.AJAX.Submit('j_id0:j_id60',event,{'similarityGroupingId':'j_id0:j_id60:dropdownpanel:j_id64','oncomplete':function(request,event,data){resetItems()},'parameters':{'j_id0:j_id60:dropdownpanel:j_id64':'j_id0:j_id60:dropdownpanel:j_id64'} } )" style="display: none;"> 
  <option value="Generation 3" selected="selected">Generation 3</option>
  <option value="Generation 2">Generation 2</option>
  <option value="Generation 1">Generation 1</option>
</select>

It works perfectly fine in Chrome, Firefox, Safari and IE Edge. Doesn't work in IE up to 11. Selecting an option do nothing.

The error which I'm getting when page is loaded:

[Error] Could not retrieve a valid progID of Class: Microsoft.XMLDOM. (original exception: ReferenceError: Can't find variable: ActiveXObject)
It is thrown from Sarissa.js

The error when I'm selecting the option element:
TypeError: undefined is not an object (evaluating 'A4J.AJAX.Submit')

Is there any solution to fix that?
Thank you!
 
For example, Object A has 2 record types: RTX, RTY.
Is it possible to create a field F only for RTX, it means this field cannot be selected by RTY, such as layout or somrthings else.
Hi guys,

Can we display a related list based on some picklist value. Like i have opportunity standard object and equipment as a custom object.
In opportunity picklist i have three values. i want to display equipment related list on selection of a particular value. How can we do that?
I'm bit confused with this terms, when should I go for list<sobject> and when for sobject only? Can you please explain when to use list<list<set>>?
Suppose I've a list of fruits like 
List<string> fruits = new List<string> {'mango','papaya','orange','mango'};

then how can I assign this values to set?

for(integer i =0; i<fruits.size(); i++)

set<string> fruits1 = fruits[i];
}

The above code declaration is correct?
Hello 

I'm getting the error Attempt to de-reference a null object, for a vfp test class. There is no line number or another information. Having a tough time trying to debug the issue.

Thank you.
I have a wrapper class which have a boolean value for checkbox and an identifier class, in Identifier class, there is a lookup field attribute_value__c. It seems that I can not get the picked value for attribute_value__c field in controller, always return null value. any clues?

 <apex:pageBlockTable id="tblIden" value="{!IdentifiersList}" var="i">
                    <apex:column width="25px">                       
                            <apex:inputCheckbox value="{!i.selected}" />                               
                    </apex:column>
                    <apex:column value="{!i.identifier.Identifier_Type__c}" headerValue="Type"/>  
                    <apex:column value="{!i.identifier.name}" headerValue="Name"/>  
                    <apex:column >
                        <apex:facet name="header">Attribute Value</apex:facet>
                        <apex:inputField value="{!i.identifier.Attribute_Value__c }" rendered="{!IF(i.identifier.Identifier_Type__c='Attribute','True','False')}"/>                     
                    </apex:column>
                </apex:pageBlockTable>
In controlling access to records module(Data Security), one of the sharing model mentioned is "controlled by parent" and the description mentioned is:

"A user can perform an action (such as view, edit, or delete) on a contact based on whether he or she can perform that same action on the record associated with it". 

How is this set up? And in which situation is this applicable?
I wrote this code
 i am getting error Attempts to de reference to null object


public class sample2 {

    public List<AggregateResult> Result {get;set;}    
    public List<Summary> SummaryList {get;set;}
    public List<Account> AcctList;
    public Map<Id, Account> IdAccount;
    List<Id> Ids;
    
    public void show() {
        SummaryList = new List<Summary>();
        Result = new List<AggregateResult>();
        Ids = new List<Id>();
        AcctList = new List<Account>();
        IdAccount = new Map<Id, Account>();
        
        Result = [SELECT Count(Id) Total , AccountId FROM Contact GROUP BY AccountId];               
        
        for(AggregateResult a : Result) {   
            Ids.add((Id)a.get('AccountId'));
        }
        
        AcctList = [SELECT Name FROM Account WHERE Id IN : Ids];
        
        System.debug('Account List' + AcctList);
        
        for(Account a : AcctList) {
            IdAccount.put(a.Id, a);            
        }
        
        System.debug('Ids and Accounts are ' + IdAccount);
                
        for(AggregateResult a : Result) {
            Account TempAcct = new Account();            
            tempacct= IdAccount.get((Id)(a.get('AccountId')));
          
            system.debug('Account Name is ' + TempAcct.acctName);
            SummaryList.add(new summary(a));                
        }    
    }
    
    public class Summary {
        public Integer Total {get;set;}
        public string AcctName {get;set;}
        
        public Summary(AggregateResult a, string AccountName) {
            Total =  (Integer)a.get('Total');
            AcctName = AccountName;
        }
    }

}
Hi,
I want to load 20000 accounts and 20000 contacts in my developer org but I get: 
storage limit exceeded error ..
I deleted all the other data present in the org and still have this issue
is there a way to have this amount of data ( 20000 accounts and 20000 contacts) 
in a developer org  please ?
Here I have one Account (standard) object and Opportunity(custom )
Eg:   HP(Account) have 1000 oppotunity 
In VF page I want to see How Many Records Are crewatd In last week ,This week,Last month,This month  how to display Based On calender wise.
I have a problem where on a custom object the cancel button takes you back to the incorrect record.

To get this I have a related list within a ticket and I press New which takes me in from a reference 00012 I then press cancel and it will take me back to a reference 00001. Is there a way of making the cancel button take you back to the correct ticket.

The buttons I am using is a custom button so it populates some fields automatically.
I have created an search functionality in lightning which fetches records and display it in table format(6 columns).
In iPhone 5,6,6+ this table is displaying only 3-4 columns and I want to show all columns.If I decrease table's font size then in Ipad/Desktop it looks bad. Please guide.

Thanks
Shoyab
I have ceated to fields Mobile Number and SMS Description using VF Page. I'm able to create the task, When I click the button submit, these to field details added to activities in account. How to do it.Please anybody help me on this.
 
Hi,

Im trying to solve a problem for days please help. I would like to make my phone numbers on that contact page "clickable". When someone click on the number it should go to a link:

tel://contact.mobile number

(We use Cisco Jabber,any number in the browser typed in the format tel:// will be dilalled.)

Im tired with the HYPERLINK funkcton but i still cant. Anibody have any idea how to solve this?
V

Hi,

While calling out other system's webservices from salesforce org. This 401 invalid seesion id  error is being prompted. Even though i had mentioned Username and password in header of HttpRequest. Is there any workaround to fix it.

Code snippet has been attached below.


Http h = new Http();
Httprequest request = new Httprequest();
request.setEndpoint('https://ap2.salesforce.com/services/apexrest/Accounts/0012800000XNqPO/contacts');
request.setMethod('GET');
String username = 'xxxxx';
String password = 'xxxx';
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
request.setHeader('Authorization', authorizationHeader);
Httpresponse response = h.send(request);
System.debug(response.getBody());




Any help, would be appreciate.

Thanks,
Abhi

Hi folks...
  Here is my vf page code and controller code. But I am getting an error called Unknown property 'ContactgivenId.con. I have defined getter and setter in my controller. Any help will be appreciated.. Thanks in advance..
Vf page code_______________________
<apex:page id="pgId" controller="ContactgivenId">
    <Apex:form>
        <apex:pageBlock>
            <Apex:pageblockSection title="Accounts">
                <apex:pageBlockTable value="{!acct}" var="account">
                    <Apex:column headervalue="Account id">
                        <Apex:outputPanel >
                            <Apex:outputText value="Click" />
                            <apex:actionSupport event="onclick" action="{!getContact}" rerender="contactBlock" >
                                <Apex:param name="accountId" assignTo="{!acctId}" value="{!account.Id}"/>
                            </apex:actionSupport>
                                   
                        </apex:outputPanel >
                    </apex:column>
                    <Apex:column headervalue="Account name">
                        <Apex:outputField value="{!account.Name}" />
                    </apex:column>
                </apex:pageBlockTable>
            </Apex:pageblockSection>
        </apex:pageBlock>
       
        <apex:pageBlock id="contactBlock">
            <Apex:pageblockSection title="Contacts">

                <apex:pageBlockTable value="{!con}" var="contact">
                    <Apex:column headervalue="Contact id">
                        <Apex:outputField value="{!contact.Id}"/>
                    </apex:column>
                    <Apex:column headervalue="Contact name">
                        <Apex:outputField value="{!contact.firstName}" />
                    </apex:column>
                </apex:pageBlockTable>
            </Apex:pageblockSection>

        </apex:pageBlock>

    </apex:form>
</apex:page>
___________________________________________Controller________________________________
public class ContactgivenId {
    public List<Account> acct{get; set;}
    public List<Contact> cont{get; set;}
    public String acctid{get; set;}
    public ContactgivenId(){
        acct=new List<Account>();
        cont= new List<Contact>();
        acct=[select id,name from account LIMIT 10];
        
    }
    public void getContact(){
        cont=[select firstname, lastname, phone from contact where account.id= :acctid];
    }
}