• justin_sfdc
  • NEWBIE
  • 282 Points
  • Member since 2013

  • Chatter
    Feed
  • 7
    Best Answers
  • 3
    Likes Received
  • 2
    Likes Given
  • 17
    Questions
  • 116
    Replies
sir, i am using list program.  This is a apex class program.  here i am getting all the colors vales at VF page. VF page and Apex page is working well.  here my doubt is how can i use this apex program without constructor.  please help. thanks in advance. 
 
public class listcolor
{
public list<string> color{set;get;}

public listcolor()
{
color=new list<string>{'red','white','green'};

list<string> myval=new list<string>();
myval.addall(color);

}
}

I tried this, but it is giving error. 
 
public class listcolor
{
public list<string> color{set;get;}

mycolors();


public void mycolors()
{
color=new list<string>{'red','white','green'};

list<string> myval=new list<string>();
myval.addall(color);

}
}

OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR 





public class listcolor
{
public list<string> color{set;get;}

public list<string>  mycolors()
{
color=new list<string>{'red','white','green'};

list<string> myval=new list<string>();
myval.addall(color);

return color;

}
}

Vf page ( for your reference):- 
 
<apex:page controller="listcolor" title="list of colors">
<apex:form>
<apex:pageblock>

<apex:pageblocktable var="a" value="{!color}">
<apex:column headervalue="colors" value="{!a}" />

</apex:pageblocktable>
</apex:pageblock>


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

 
 I have a custom lookup filed Asset__c  at custom object Service_Report__c.  Service_Report__c is a child object of standard case object i.e. case is parent of Service_Report__c
Now I want to write a apex trigger to update InstallDate and Site__c fields at asset when Asset__c!=null, when I create and update record at custom object  Service_Report__c.
 InstallDate(asset) = Date_of_Site_Visit_To__c(custom lookup field at Service_Report__c)
 Site__c(custom lookup field at asset) =  Site__c(custom lookup field at case)
 Asset object fields: InstallDate(Standard field),  Site__c(lookup)
 Service_Report__c  object fields: Case__c(lookup), Asset__c(lookup), Date_of_Site_Visit_To__c(date field)
 Case object fields: Site__c(lookup)
Hi,

I've got this Trigger on Leads:

trigger UpdateLeadOwner on Lead (before insert) {
    for (Lead leadInLoop : Trigger.new) {
    // Retrieve owner from Account record based on email domain name
    list <Account> acct = [Select OwnerId from Account WHERE Domain_1__c = :leadInLoop.Domain__c Limit 2];
        if (acct.size() == 1) {

    System.debug('account owner id is: ' + acct[0].OwnerId);
    leadInLoop.OwnerId=acct[0].OwnerId;
        }
    }
}

I need to update the trigger so that the Lead source field  "LeadSource" does not contain either of these picklist values, "Contact Us" or "Reprint" but I can't figure out where it should go.  Help, please?  Thanks!
Good evening, 

my second post today...
so I'm trying to create a trigger that will update the status of a custom object (Sales_Order__c) based on if a related task is open or if task is completed:
Open Task > Update Sales Order Status to "Pending Question"
Completed Task > Update Sales Order Status to "Sales Order Revised"

I'm not close to being a developer, so some of my coding probably has some major flaws:

trigger SalesOrderUpdateonTask on task (after insert, after update ){
set<id> Sales_Order = new set<id>();
for(Task ts : trigger.new)
{
Sales_Order.add(ts.whatid);
Sales_Order =[Select status__c from Sales_Order__c  where id in :Sales_Order];
if(String.valueOf(ts.whatId).startsWith('a1M')==TRUE)
{
Sales_Order__c.Status__c='Pending Question';
update Sales_Order;
}
}
}

On save, get a compile error: illegal assignment from List <Sales_Order__c> to set <id> at line 6...also, have another trigger to Update on task completion:


trigger SalesOrderStatusUpdate on Task (after update)
{
List<ID> Sales_Order = new List<ID>();

for(Task t: Trigger.new)
{
if(t.status == 'Completed')
{
Sales_Order__c.add(t.whatid);
}
}
Map<ID, Sales_Order__c> objMap = new Map<ID, Sales_Order__c>([select id, status__c from Sales_Order__c where id in :Sales_Order__cIDList ]);
List<Sales_Order__c> objList = new List<Sales_Order__c>();
for(Task t: Trigger.new)
{
if(t.Status__c == 'Completed')
{
Sales_Order__c so = objMap.get(t.whatid);
so.status__c = 'Sales Order Revised';
//update remaining fields.
objList.add(so);
}
}
if(objList.size() > 0)
update objList;
}

not sure how to change the variable Sales_Order__c IDlist on line 12 where it will accept, and how to combine the two triggers together into one.  Again, excuse the basic errors since i'm not a developer, but trying to find existing codes that is similar to what i'm looking for.  Thanks once again.


Is there a way to call out a standard controller for ex. "Account" from an already existing custom controller? What is the best practice for using a custom controller and standard controller together from one apex class. or is my thinking is all wrong? Thanks
  • February 11, 2014
  • Like
  • 0
Hey everyone,

Let me briefly explain the trigger I wrote (my frist trigger actually). On the opportunity, we have a look-up field to other opportunities called 'Renewed Opportunity'. The idea is that when you create an opp that is a renewal, you use that field to reference the previous opportunity that is being renewed.

The trigger looks at the stage of the new renewal opp and updates a field on the referenced 'Renewed Opporunity' called 'Renewal Status'. The goal is to be able to see if an opp ended up renewing or not.

The issue here is that many of our older opportunities don't meet the validation rules we currently have in place. So if you populate that look-up field with an opp with missing data, you'll get an error message preventing you from updating the new, renewal opp you're creating.

Obviously, one solution would be to go back and update all our older opps, but that's practically impossible. So here is my question:

1) Is there something I can write in either the trigger or the validation rules to set up a bypass? For the validation rules, I tried writing in 'NOT(ISCHANGED(Renewal_Status__c))', but it seems that as long as a record is referenced, the validation rules will be required. The trigger doesn't even have to update the record.

2) If option 1 is not possible, is there a way to write an error message in the trigger that at least explains to the user in a clear manner that they have to update the referenced opp? I'd also like to list in the error the validation rules that must be met, but that would be a bonus.

In case you want to take a look at my trigger, here it is:


trigger RenewalProcess on Opportunity (after insert, after update) {
   
   Set<String> allOpps = new Set<String>();
    for(Opportunity renewalOpp : Trigger.new) {
        if (renewalOpp.Renewed_Opportunity__c != null) {
            allOpps.add(renewalOpp.Renewed_Opportunity__c);
         }
    }

    List<Opportunity> potentialOpps = [SELECT Id FROM Opportunity WHERE Id IN :allOpps];

    Map<String,Opportunity> opportunityMap = new Map<String,Opportunity>();
        for (Opportunity o : potentialOpps) {
            opportunityMap.put(o.id,o);
        }
     
     List<Opportunity> oppsToUpdate = new List<Opportunity>();
       
        for (Opportunity renewalOpp : Trigger.new) {
            if (renewalOpp.Renewed_Opportunity__c != null && renewalOpp.StageName.equals('Closed Won')) {
                Opportunity renewedOpp = opportunityMap.get(renewalOpp.Renewed_Opportunity__c);
                renewedOpp.Renewal_Status__c = 'Renewed';
                oppsToUpdate.add(renewedOpp);
            }
            else if(renewalOpp.Renewed_Opportunity__c != null && !renewalOpp.IsClosed) {
                Opportunity renewedOpp = opportunityMap.get(renewalOpp.Renewed_Opportunity__c);
                renewedOpp.Renewal_Status__c = 'In Negotiations';
                oppsToUpdate.add(renewedOpp);
            }
            else if(renewalOpp.Renewed_Opportunity__c != null && (renewalOpp.StageName.equals('Closed Lost') || renewalOpp.StageName.equals('Closed Stalled'))) {
                Opportunity renewedOpp = opportunityMap.get(renewalOpp.Renewed_Opportunity__c);
                renewedOpp.Renewal_Status__c = 'Did Not Renew';
                oppsToUpdate.add(renewedOpp);
            }
           
           
        }
   
    update oppsToUpdate;
   
}



Let me know if you need anymore info from me!
-Greg
HI,

   In Visualforce page i have 2 input texts,if i write any thing in input text1, automatically  inputtext2 comes visiable, i need picklist funcationality in-between fields in visualforce page how can i get this.


<apex:page controller="deptext">
  <apex:form >
  <apex:inputText value="{!inputValue1}" id="theTextInput1"/><br/>
  <apex:inputText value="{!inputValue2}" id="theTextInput2"/>
  </apex:form>
</apex:page>

My Apex Code

  public class deptext {

 
   public String inputValue1 {get;set;}
   public String inputValue2 {get;set;}

    public String getInputValue1() {
        return null;
    }

     public String getInputValue2() {
        return null;
    }


}

when i enter in first input text at that time input text2 be visiable how can i achieve this.
Hi everyone,
I am currently designing a vf page where I am using html input tag but I am not sure how to pull that value into the controller. If I use <apex:inputText> component it works but I want to use html input tag in the vf page rather. Below is a simple example of what I want to do. If there is a textbox and a button then how do I retrieve that value in a controller when the button is clicked.

VF Page:
<input type="text" name = "name"/>
<input type= "submit" value = "submit"/>

Controller:
public string name {get; set;}

public void submit() {
   System.debug('The value entered for name is: '+ name);
}

Any help is appreciated.

Thanks!
Hi,

I am currently sending the infomation to .net handler via Outbound msg. The handler is able to receive my message but not being able to parse into the namespace; <sf:name> and all.
What should be the xmlns for the notifications and how would you parse into the sf: namespace sent from SFDC to .net.

Thanks!

Hi there,

I am retreiving binary Excel value from webservice callout which I managed to convert to blob. It works fine if I create a document for this value like this;
        blob image = res.getBodyAsBlob();
        Document d = new Document();
        d.name = 'CustomerByLocationFile.xls';
        d.body = image;
        d.folderId = UserInfo.getUserId();
        insert d;
        system.debug(d.id);
Now,
I want to be able to display this same file in the VisualForce page or make it download in Excel format;
I have tried using the attribute; contenttype="application/vnd.ms-excel#CustByLocation.xls" in the page tag, which downloads the excel file but it is in not Readable format.

If someone could please help me out on displaying these properly in excel download or even in VFpage that would be of great help.

Thanks in advance!

Hi everyone,

I am currently performing the POST callout to an external system upon which it sends me binary Excel file. When I add the condition in my VFpage to download the file as Excel, the file gets downloaded, but its in binary format and not readable. 

Is there any way we can convert it to UTF-8.

Below is the code of the response the Handler is sending back?
var HandlerResponse = (HttpWebResponse)request.GetResponse();
            MemoryStream mStream = new MemoryStream();
            HandlerResponse.GetResponseStream().CopyTo(mStream);

            byte[] bArray = mStream.ToArray();

            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = HandlerResponse.ContentType;

            string strDisposition = HandlerResponse.GetResponseHeader("Content-Disposition");
            Response.AddHeader("Content-Disposition", strDisposition);

            Response.BinaryWrite(bArray);
            Response.Flush();
            Response.Close();

I believe i should be adding the ContentType for the response too so that it can handle the response. Please suggest me of the ideas of how this can be achieved or if it can be?


Thanks, 
Justin~sfdc
Hi there,
I am writing a webservice callout which is triggered on clicking a link in an Account detail page; Upon the click of the link, the code will go to the external system and get the record from the other system based on the account I clicked the link from and display in a VF page.
So far, I've got to the point where i could retrieve from the endpoint but I do not know how to put the condition based on which Account Id i click the link from?

<!-----Visualforce Page-------------->
<apex:page controller="GetRestfulExample" action="{!fetchData}" contentType="text/plain">
     {!response}
</apex:page>

<!---------Controller----------->
public class GetRestfulExample {
    private final String serviceEndpoint= 'http://headers.jsontest.com/';
    public String Response { get; set;}
    public String Headers { get; set; }
   
    public void fetchData() {
        getAndParse('GET');
    }

  public void getAndParse(String GET) {

    // Get the XML document from the external server
    Http http = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint(serviceEndpoint);
   
    req.setMethod('GET');
    HttpResponse res = http.send(req);

    System.debug(res.getBody());
     this.response=res.getBody();
  }
}

Where can I put the condition to just display the fields for this account I am currently in?

Please throw me some ideas!

Thanks,
justin~sfdc
Hi,
Wanted to grab few ideas on how to get this done and working. 

I need to be retreiving about 30-40 fields based on an external id doing a RESTFUL webservice call. Therefore, I do know that I would be writing a GET Method, right. But the data i retrieve, I need to display in a vf page and do not want to be storing in Salesforce. I have whatsoever no clue on how to retrieve and display the data returned from the callout, especially in VF page so please throw me some ideas of how it can be achieved. 

Thanks,
justin~sfdc
Hi,
I need to be able to create a username and password in Salesforce and send that out in email to the particular user. The user should enter that username and password to login to a secured webpage (an external webpage). And after the user has filled in the form in that webpage, I want to go ahead and delete the records for those fields so that they wont be able to log back in.

I can put the userName to be the name of the user of sth but how can i auto generate the password.

Please let me know of any suggestions.

Thanks,
Justin~sfdc
Hi,
I have this error: 
execution of AfterInsert caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times):Trigger.TerritoryAccountTeamMemberUpdate: line 62, column 1
It is showing me an error in the query that I am using in the Map.
Below is the code;

trigger TerritoryAccountTeamMemberUpdate on TerritoryAccountTeamMember__c (after insert, after update, after delete) {

     set<Id> terrMembers= new set<Id>();
    //execution of after Insert or update trigger
    if (trigger.isInsert || trigger.isupdate) {
        for (TerritoryAccountTeamMember__c territoryMembers: trigger.new) {
            System.debug('-=TerritoryMembers in the list are: ' + territoryMembers);
            terrMembers.add(territoryMembers.territory__c);
        }
    }
    //execution of after delete trigger
    else if (trigger.isDelete) {
        //Loop through the list of TerritoryAccountTeamMember__c that was deleted
        for (TerritoryAccountTeamMember__c territoryMembers: trigger.old) {
            System.debug('-=-TerritoryMembers in the list are: ' + territoryMembers);           
            terrMembers.add(territoryMembers.territory__c);
        }
    }
   
    if(terrMembers.size() >0) {
        System.debug('=== This is the territory id: ' + terrMembers);
        Map<Id, Account> newMap= new Map<Id, Account>([Select id, ownerId, Territory__c, fmr__c, territory__r.name,                                                                                                                                                         territory__r.Territory_ID__c                            
                                                                                                            from Account where territory__c =: terrMembers]);

                
            System.debug('-=TerritoryAccountTeamMemberUpdate newMap value :' + newMap);
           
            //calling the helper class AccountServices and the methods in it
            //AccountServices.OnBeforeUpdate(newMap);
            AccountServices.OnBeforeUpdate2(newMap);
            AccountServices.OnAfterUpdate(newMap);
    }

}

This trigger runs perfectly fine while I run it in my dev sandbox, but it is throwing me an error in my fullcopy sandbox. Also I ran this code snippet of Map in Developer Console, where it runs smoothly;
Map<Id, Account> newMap= new Map<Id, Account>([Select id, ownerId, Territory__c, fmr__c, territory__r.name, territory__r.Territory_ID__c                                                                                                              from Account where territory__c =: 'territory ID']);
System.debug('newMap Values are: ' + newMap);

Please let me know if you have any suggestions. 

Thanks!
justin~sfdc

Hi,

 

I am using an html input tag. How do i direct it to a particular field in custom object?

 

Example: if I say input tag to be name and I want to store it in a field called FirstName which is in custom Object: "info" then how would I do it?

 

<apex:outputLabel value="name" for= "name"/>

<input type="text" id="fName" value = "{!sth that the user will input}" />

 

Thanks Much!

Justin~sfdc

Can I give an "id" the value in following manner while using <apex:inputfield> component?

 

<apex:inputField value={!x} id ="{!value}" />

 

What am trying to achieve here is; I have this inputField inside an <apex:repeat> component and I need to give it a separate id everytime this component gets repeated.

 

Any suggestion is helpful.

 

Thanks ~ justin_sfdc

Hi,

I have a VFpage where in I am using the <apex:repeat> component which will repeat the code depending on number of items in the object. Inside the <apex:repeat> component, I have <apex: inputField> components; this are the fields that are being repeated. currently, in the <apex:inputField>, I gave them a regular id="test1", but the problem that I am facing is if there are 3 records in the object then the repeat component will put three sections in the VF page. In this case, all three inputFields are having the same id. 

I want to give them all the unique id's no matter how many records we have in the other object.

 

Please throw out any ideas you have for this problem. I would really appreciate it.

 

Thanks-in-Advance,

Justin~sfdc

Hi, I needed an intel on if I could send an email notification anytime a particular validation rule is turned off? Any suggestion is helpful.

 

Thanks~

Justin_sfdc

Hi,

 

I need to fire an error on click of a custom button, which creates a new record. There is an object called Path, and another objects are: Opportunity and Boats. An opportunity can have multiple boats. I need to fire an error message when a New Path custom button is clicked and the condition for this to happen is when a field; which is a number field in opportunity is less than combination of shipment number fields in boats object.

 

Please suggest if there are any other ways to do this as well.

 

Thanks!

 

Hi, 

I want to get some suggestions on one of the issues I am having. 

 

I want to change the data type for one of the custom objects. Currently, the field is picklist and is being used in multiple apex classes and triggers. I need to change it to Text field. I have come up with two solutions so far but I am not sure if any of these is the best practice. Please correct me if I am missing anything.

1) First solution is to comment the codes where the field is being used and then change the dataType and again uncomment back the codes. With this process, when I have to deploy it to production, it might be a bigger risk as it is being used in multiple places.

2) Second solution that I could think of is; creating a new field with datatype 'Text', and copying the existing records to this new field. Then replacing this new field with old field in the Apex classes and triggers.

 

Please suggest me if there are any other solutions.

Also, please suggest how would I revert this whole process if something goes wrong (any suggestion except the refresh of the sandbox would be appreciated).

 

Thanks in Advance!

Justin.

hi everyone,

 

I have a class which shares all the records that are in an account with all the contacts in that particular account. Meaning, Account A has contacts c1, c2, c3. If account A has lets say 10000 records then the same number of records should be shared with contacts c1, c2 and c3. Also, if a new contact c4 is created under that account A, then that contact c4 should also have 10000 records. Anytime a new record is added to that account, all these contacts should have that updated records.

 

The code I have works if the record size is less, but I have an account with 78K records so the code hits governor limits.

The records are being fetched to that account from another class Order, Items, Price. I have triggers in all these classes to this class that is supposed to share the records.

 

Does anyone have any suggestion on what can be done to resolve this issue. Any suggestion is helpful.


Thanks!

Hi all, 

I have an issue in my controller. Basically, I have a VF page that displays data, and to filter the data I have two checkbox value>0, and remaining>0. Now, when I click on remaining>0 and click on the button, the code runs well and displays me the correct output. The number of data after this filter is less than thousand. But on the other hand, when i click value>0, and click the button, it throws me an error saying Apex Heap Size too large. In this case, the total number of data it should output is almost 20K. I think it is showing the error because of too many data in it. 

 

Please let me know if you have suggestion on resolving this issue.

Thanks!

Hey guys,

I am trying to download the records that I have in Visualforce page to excel. I am able to download the file in all other browsers except IE8. I do not want to download the whole VF page. I want to download the records that are in the VF page. Basically, the VF page has excel icon, which when clicked should download the records in excel format. I have tried using cache="true" and contenttype="application/vnd.ms-excel#filename.xls" but this downloads the whole VF page at the time of loading. I want to be able to download the records at the click of the icon instead. Any kind of help is appreciated.

Thanks!

Hi,

I am currently sending the infomation to .net handler via Outbound msg. The handler is able to receive my message but not being able to parse into the namespace; <sf:name> and all.
What should be the xmlns for the notifications and how would you parse into the sf: namespace sent from SFDC to .net.

Thanks!

Hi there,

I am retreiving binary Excel value from webservice callout which I managed to convert to blob. It works fine if I create a document for this value like this;
        blob image = res.getBodyAsBlob();
        Document d = new Document();
        d.name = 'CustomerByLocationFile.xls';
        d.body = image;
        d.folderId = UserInfo.getUserId();
        insert d;
        system.debug(d.id);
Now,
I want to be able to display this same file in the VisualForce page or make it download in Excel format;
I have tried using the attribute; contenttype="application/vnd.ms-excel#CustByLocation.xls" in the page tag, which downloads the excel file but it is in not Readable format.

If someone could please help me out on displaying these properly in excel download or even in VFpage that would be of great help.

Thanks in advance!

Hi,
Wanted to grab few ideas on how to get this done and working. 

I need to be retreiving about 30-40 fields based on an external id doing a RESTFUL webservice call. Therefore, I do know that I would be writing a GET Method, right. But the data i retrieve, I need to display in a vf page and do not want to be storing in Salesforce. I have whatsoever no clue on how to retrieve and display the data returned from the callout, especially in VF page so please throw me some ideas of how it can be achieved. 

Thanks,
justin~sfdc
I am unable to resolve my test class. Before including trigger.oldmap it was 80% coverage. Now it is 0%. Any suggestions could be helpful for me.

Thank you.

Trigger:
trigger populateOpportunityfromContact on Opportunity (before insert , before update)
{
    
    Set<ID> ConIds = new Set<ID>();

    for(Opportunity opp : trigger.new)
    {
          ConIds.add(opp.RSM_Shipping_Contact__c);    
    }

    list <contact> conlist = [SELECT Email,Id,MailingCity,MailingCountry,MailingPostalCode,MailingState,MailingStreet,Phone FROM Contact where id IN:ConIds];

     MAP<ID , contact> mapCon = new MAP<ID , Contact>();
     for(Contact c : conlist)
     {
        mapcon.put(c.id,c);
     }

     for(Opportunity opp : trigger.new)
     {
      if(trigger.oldmap.get(opp.Id).RSM_Shipping_Contact__c != opp.RSM_Shipping_Contact__c)
      {

        if(opp.RSM_Shipping_Contact__c!=null)
        {
        if(mapcon.containskey(opp.RSM_Shipping_Contact__c))
        {
          contact c = mapcon.get(opp.RSM_Shipping_Contact__c);
          opp.Shipping_Street__c = c.MailingStreet;
          opp.Shipping_City__c = c.MailingCity;
          opp.Shipping_State__c = c.MailingState;
          opp.Shipping_Country__c= c.MailingCountry;
          opp.Shipping_postal_code__c = c.MailingPostalCode;
          opp.Shipping_Email__c = c.Email;
          opp.Shipping_Phone__c = c.phone;
        }
       
        }
        
        else
        {
            
          opp.Shipping_Street__c = null;
          opp.Shipping_City__c = null;
          opp.Shipping_State__c = null;
          opp.Shipping_Country__c= null;
          opp.Shipping_postal_code__c = null;
          opp.Shipping_Email__c = null;
          opp.Shipping_Phone__c = null;
            
        }
       
     }
    }
        
}

Test Class:
 
@istest

public class populateOpportunityfromContactTestclass
{
     @testSetup static void setup() 
      {
                
        contact c = new contact();
        c.lastname = 'Gopi Jayaram';
        c.mailingstreet = '1409 Roper Mountain Road';
        c.mailingcity = 'Greenville';
        c.mailingstate = 'South Carolina';
        c.mailingcountry = 'United State of America';
        c.mailingpostalcode = '29615';
        c.email = 'gopijayaram@gmail.com';
        c.phone = '4053786543';
        insert c;
        
        
        opportunity o = new opportunity();
        o.name = 'Gopi Jayaram ATT';
        o.RSM_Shipping_Contact__c = c.id;
        o.stagename = 'prospecting';
        o.closedate = Date.today();
        insert o;

     }
     
     Static testMethod void insertItemNull()
     {
         Opportunity op = [Select id, name,Shipping_Street__c from opportunity where name = 'Gopi Jayaram ATT' ];
        // contact ct = [Select id,email,phone,mailingstreet,mailingcity,mailingstate,mailingcountry,mailingpostalcode from contact where name = 'Gopi Jayaram' ];
         System.assertnotequals(op.Shipping_Street__c,null);
     } 
      Static testMethod void insertItem()
     {
         Opportunity op = [Select id, name,Shipping_Street__c from opportunity where name = 'Gopi Jayaram ATT' ];
        contact ct = [Select id,email,phone,mailingstreet,mailingcity,mailingstate,mailingcountry,mailingpostalcode from contact where name = 'Gopi Jayaram' ];
         System.assertequals(op.Shipping_Street__c,ct.mailingstreet);
     } 
     
}

 
How to Schedule a batch Apex using system.schdule with code not through UI and where to write it ,
Below is my sample code:

public class BatchLeadDelete implements database.Batchable<sobject>
{
    list<lead> llist=new list<lead>();
    public string query='select id,name,Phone from lead';
    public string flag='12345';
    
    public database.querylocator start(database.BatchableContext bc){
       return database.getQueryLocator(query); 
  }
    public void execute(database.BatchableContext bc,list<lead> le){
        for(lead l:le){
            if(l.Phone==flag)
            {
                llist.add(l);
            }
                
        }

      delete llist;             
    }
    public void finish(database.BatchableContext bc){
        
    }
 }

I called the above class with below code

BatchLeadDelete l=new BatchLeadDelete();
    database.executeBatch(l,50); 
While i am trying to create record using report buiilderf and save with the name it shows me error like this in the Screen shot but by mistake i created same named record earlier but not able to find that earlier created report.

User-added image
Please telll me how i find previous report that  I created  earlier on Opportunity object and how should i edit that?

Thanks in advance.
Hi Experts,

Am trying to call a method into VF, but am getting the below error
User-added image


here is my class

Public class RBGeneratorController{
List<account> selectacct;


Public List<account> getAllAccounts()
{
    List<account> allaccts = [Select ID,Name, Industry, Type, Billingstreet from Account limit 5];
   return allaccts;
}    


Public void selectacct()
{
    String selaccountid = System.currentPagereference().getParameters().get('accid');
    Account acc = [Select ID,Name, Industry, Type, Billingstreet from Account where Id=:selaccountid];
    selectacct =  new List<account>();
    selectacct.add(acc);
}
//Public List<account> getselectedAccount()
//{
 //   return selectacct;
//}
}


here is VF page


<apex:page>
<apex:form>
<apex:pageblock id="PB" title="Available Generators">
               <apex:pageblocktable id="PBT" value="{!AllAccounts}" var="allaccts">
                    <apex:column headervalue="Generatos">                    
                       <apex:actionsupport action="{!selectacct}" event="onclick" rerender="allcons">  
                        <input type="radio" />                    
                            <apex:param name="accid" value="{!allcon.Id}">
                        </apex:param></apex:actionsupport>                            
                    </apex:column>    
                    <apex:column headervalue="Name">
                        <apex:outputfield value="{!allcon.Name}">
                    </apex:outputfield></apex:column> 
                    <apex:column headervalue="Industry">
                        <apex:outputfield value="{!allcon.Industry}">
                    </apex:outputfield></apex:column>  
                    <apex:column headervalue="Type">
                        <apex:outputfield value="{!allcon.Type}">
                    </apex:outputfield></apex:column>  
                    <apex:column headervalue="BillingStreet">
                        <apex:outputfield value="{!allcon.Billingstreet}">
                    </apex:outputfield></apex:column>  
                </apex:pageblocktable>
</apex:pageblock>

</apex:form>

</apex:page>

please help me through this

Thank you
Hi everyone,
I am currently designing a vf page where I am using html input tag but I am not sure how to pull that value into the controller. If I use <apex:inputText> component it works but I want to use html input tag in the vf page rather. Below is a simple example of what I want to do. If there is a textbox and a button then how do I retrieve that value in a controller when the button is clicked.

VF Page:
<input type="text" name = "name"/>
<input type= "submit" value = "submit"/>

Controller:
public string name {get; set;}

public void submit() {
   System.debug('The value entered for name is: '+ name);
}

Any help is appreciated.

Thanks!
Currently we have Opportunity Approval Process - when a opportunity record is submitted for approval- the approval goes to several approvers depending on the criteria listed in each step. If one BU “approves” one part of the deal and the other BU “rejects” other part, the entire deal would be "rejected”. Either the deal would have to be modified and “approved” by both Business Units, or the deal would be considered ‘dead’.

Each Business Unit is responsible for a different line of business(s). An opportunity can have mulitple lines of business. With the way the Approval Process is set up, we run the risk with the apporval request never getting to one of the Business Units. 

We want to split the approval process into two separate Approval Process. When the opportunity is submitted for approval. Two Approval Process are fired off at the same time. Is this possible?
Hi All,

I have to compare new and old values for few fields of a object.How can it be done using custom settings and used in apex class?
Can you help me few line of codes?
Thanks for helping
 
sir, i am using list program.  This is a apex class program.  here i am getting all the colors vales at VF page. VF page and Apex page is working well.  here my doubt is how can i use this apex program without constructor.  please help. thanks in advance. 
 
public class listcolor
{
public list<string> color{set;get;}

public listcolor()
{
color=new list<string>{'red','white','green'};

list<string> myval=new list<string>();
myval.addall(color);

}
}

I tried this, but it is giving error. 
 
public class listcolor
{
public list<string> color{set;get;}

mycolors();


public void mycolors()
{
color=new list<string>{'red','white','green'};

list<string> myval=new list<string>();
myval.addall(color);

}
}

OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR 





public class listcolor
{
public list<string> color{set;get;}

public list<string>  mycolors()
{
color=new list<string>{'red','white','green'};

list<string> myval=new list<string>();
myval.addall(color);

return color;

}
}

Vf page ( for your reference):- 
 
<apex:page controller="listcolor" title="list of colors">
<apex:form>
<apex:pageblock>

<apex:pageblocktable var="a" value="{!color}">
<apex:column headervalue="colors" value="{!a}" />

</apex:pageblocktable>
</apex:pageblock>


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

 
Hi,
I designed one webpage. I want to get the data from the web page and i want to store in one custom object. How many ways we can do it?
 I have a custom lookup filed Asset__c  at custom object Service_Report__c.  Service_Report__c is a child object of standard case object i.e. case is parent of Service_Report__c
Now I want to write a apex trigger to update InstallDate and Site__c fields at asset when Asset__c!=null, when I create and update record at custom object  Service_Report__c.
 InstallDate(asset) = Date_of_Site_Visit_To__c(custom lookup field at Service_Report__c)
 Site__c(custom lookup field at asset) =  Site__c(custom lookup field at case)
 Asset object fields: InstallDate(Standard field),  Site__c(lookup)
 Service_Report__c  object fields: Case__c(lookup), Asset__c(lookup), Date_of_Site_Visit_To__c(date field)
 Case object fields: Site__c(lookup)
Could any one help in how to deploy .object files in salesforce
I have tried this code for custom button for single click email sending. Unfortunately It is not working and showing error. Could anyone tell me where I am doing wrong and correct me please.

Thank you.
location.replace('/email/author/emailauthor.jsp retURL=/{!Opportunity.Id}&p24="varunreddypenna@gmail.com,v.reddy@thegordiangroup.com"&template_id="00Xj0000000J8sI"&p3_lkid={!Opportunity.Id}&p3={!Opportunity.Name}&p26={!User.Email}&p5="penna.janareddy@gmail.com"&save=0')
User-added image
User-added image

 
Hi,

I would like to have a validation rule when a opportunity have product added that proposal got to have contact as well.
We have a pick list field in Account object. Values of the picklist are X and Y. Now I would like to hide or restrict access to records which have picklist value as X for certain profile called Operations. So this profile users should be able to see only records with picklist value Y but not X.

I have tried different ways but could not get it. Any insights could be helpful.

Thank you.
how to pass value from vf page to controller ??
  • December 07, 2014
  • Like
  • 0
HI,

   In Visualforce page i have 2 input texts,if i write any thing in input text1, automatically  inputtext2 comes visiable, i need picklist funcationality in-between fields in visualforce page how can i get this.


<apex:page controller="deptext">
  <apex:form >
  <apex:inputText value="{!inputValue1}" id="theTextInput1"/><br/>
  <apex:inputText value="{!inputValue2}" id="theTextInput2"/>
  </apex:form>
</apex:page>

My Apex Code

  public class deptext {

 
   public String inputValue1 {get;set;}
   public String inputValue2 {get;set;}

    public String getInputValue1() {
        return null;
    }

     public String getInputValue2() {
        return null;
    }


}

when i enter in first input text at that time input text2 be visiable how can i achieve this.

Hi,

 

My requirement is to display the blob content on the page, in fact i am making a callout to external webservice and getting a file content in Base64 string format (now we can covert it to Blob). But not able to display this content in correct format, as i tried with different things like -

 

1. converted Base64 in Blob and tried to display but it's displaying something "core.filemanager.FileBlobValue@bd9997c " on the page

2. Directly tried to display Base64 string then obviously it's displaying raw string (very large)

etc.

 

I want to display that content in original format, it can be of any type (pdf, xls, doc,rtf etc).

 

Any help would be appreciate.