• Yoganand Gadekar
  • SMARTIE
  • 632 Points
  • Member since 2012

  • Chatter
    Feed
  • 20
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 261
    Replies
Create fieldset on Contact Object and render them based on the criteria in visualforce,Please give me best example??

Hi All,

I'm haveing scenario like Custom button on opportunity details page.Once we click on the buttom need to validate opportunity stage as prospecting if not error should throws on detils page if yes create a new contract with prepopulated info on the contract and contract information should show on detail page.

 

Wating for help.

Hi,

Can any one pls provide idea how to achive this triggers it will be greate help for me.

1.Write a trigger to check only one opportunity is in open status of all the opportunity

2.Write a trigger once opportunity is closed only Admin can delete or  update the opportunity

 

Waiting for nay help pls.

 

Let me explain. I have an structure where I have three Objects, Contact, Benficio__c, Sayana__c. One Sayana__c have many Contacts, and one Contact have many Beneficios.

 

I try to display all contacts in a sayana__c and in each contact his beneficios. I have the following instructions in visualforce page.

 

<apex:pageBlockTable value="{!ContactosTodos}" var="contact" cellPadding="3" border="1" columnsWidth="50px,110px,60px,60px,230px" rules="all">
     <apex:column value="{!contact.Name}"/>
     <apex:pageBlockTable value="{!contact.Beneficio__r}" var="beneficio" cellPadding="3" border="1" columnsWidth="50px,110px,60px,60px,230px" rules="all">
         <apex:column value="{!beneficio.Name}"/>
         <apex:column value="{!beneficio.Catalogo_Beneficio__c}"/>
         <apex:column value="{!beneficio.Moneda__c}"/>
         <apex:column value="{!beneficio.monto_estimado__c}"/>
         <apex:column value="{!beneficio.proposito__c}"/>
     </apex:pageBlockTable>
  </apex:pageBlockTable>

 

For last, let me know where I can see how is the names of relations in salesforce between objects?  I think that will help me so much.

 

Regards,

Hello, everyone! 

 

I have a trouble with sorting in VF page controller. The problem is: the sort doesn't work. The records are sorted in the way i set in constructor. And i need to sort using the selected field from a list

 

------------------------------VF Page--------------------------------------------

 

<apex:page standardController="BShop__c" standardStylesheets="true" showHeader="true" sidebar="false" extensions="tablesorting">

<apex:form >
<br><h1>click <apex:commandLink value="HERE" action="https://c.ap1.visual.force.com/apex/searchSheet" /> to pass to the search page</h1></br>
</apex:form>
<apex:form >
<br></br>
<apex:pageBlock >

<apex:pageBlockSection >


<apex:pageBlockSectionItem >
<apex:outputLabel >Name</apex:outputLabel>
<apex:inputField id="Name" value="{!BShop__c.Name}"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel >ReleaseDate</apex:outputLabel>
<apex:inputField id="ReleaseDate" value="{!BShop__c.ReleaseDate__c}"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel >Type</apex:outputLabel>
<apex:inputField id="Type" value="{!BShop__c.Type__c}"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel >AdditionDate</apex:outputLabel>
<apex:inputField id="AdditionDate" value="{!BShop__c.AdditionDate__c}"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel >Price</apex:outputLabel>
<apex:inputField id="Price" value="{!BShop__c.Price__c}"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel >Available</apex:outputLabel>
<apex:inputField id="Available" value="{!BShop__c.Available__c}"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel >Total</apex:outputLabel>
<apex:inputField id="Total" value="{!BShop__c.Total__c}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>

<apex:pageBlockButtons >
<apex:commandButton id="Save" action="{!quickSave}" value="Save"/>
<apex:commandButton id="Cancel" action="{!Cancel}" value="Cancel"/>
</apex:pageBlockButtons>

</apex:pageBlock>
</apex:form>
<apex:form >
<apex:pageBlock >

<apex:selectList value="{!selectedField }" size="1">
<apex:selectOption itemValue="BShop__c.Name" itemLabel="Name"/>
<apex:selectOption itemValue="BShop__c.Type__c" itemLabel="Type"/>
<apex:selectOption itemValue="BShop__c.ReleaseDate__c" itemLabel="The Date of Release"/>
</apex:selectList>

<apex:commandButton value="Sort Table" action="{!sortMethod}"/>


<apex:pageblocktable value="{!tablesort}" var="rec">
<apex:column value="{!rec.Name}"/>
<apex:column value="{!rec.Type__c}"/>
<apex:column value="{!rec.Price__c}"/>
<apex:column value="{!rec.Total__c}"/>
<apex:column value="{!rec.ReleaseDate__c}"/>
<apex:column value="{!rec.AdditionDate__c}"/>
<apex:column value="{!rec.Available__c}"/>
</apex:pageblocktable>
</apex:pageBlock>

</apex:form>

</apex:page>

 

 

----------------------------apex class-----------------------------

 

Public with sharing class tablesorting {
public list<BShop__c> tablevar{get;set;}
Public string selectedField {get;set;}
public list<BShop__c> tablesort{get;set;}

public tablesorting(ApexPages.StandardController BShop){

tablesort = [SELECT Name, Type__c, Price__c, Total__c, ReleaseDate__c, AdditionDate__c, Available__c FROM BShop__c ORDER BY Name ];
}

public void sortMethod(){

if(selectedField == 'Name')
tablesort = [SELECT Name, Type__c, Price__c, Total__c, ReleaseDate__c, AdditionDate__c, Available__c FROM BShop__c ORDER BY Name ];
else if(selectedField == 'Type__c')
tablesort = [SELECT Name, Type__c, Price__c, Total__c, ReleaseDate__c, AdditionDate__c, Available__c FROM BShop__c ORDER BY Type__c ];
else if(selectedField == 'ReleaseDate__c')
tablesort = [SELECT Name, Type__c, Price__c, Total__c, ReleaseDate__c, AdditionDate__c, Available__c FROM BShop__c ORDER BY ReleaseDate__c ];
}
}

 

 

L = Database.query('SELECT Id,Name (Select QualificationStatus__c From Qualifications__r where QualificationStatus__c =\'Success\' AND QualificationType__c=:countries) FROM Contact WHERE Firstname= :text');

 

 

Getting error

System.QueryException: unexpected token: 'Select'

 

 

 

 

 

trigger accountTestTrggr on Account (before insert, before update) {

  List<Account> accountsWithContacts = [select id, name, (select id, salutation, description, 
                                                                firstname, lastname, email from Contacts) 
                                                                from Account where Id IN :Trigger.newMap.keySet()];
	  
  List<Contact> contactsToUpdate = new List<Contact>{};

  for(Account a: accountsWithContacts){

     for(Contact c: a.Contacts){
   	  c.Description=c.salutation + ' ' + c.firstName + ' ' + c.lastname; 

   	  contactsToUpdate.add(c);
     }    	  
   }
      
   update contactsToUpdate;
}

 

Taking this fairly simple code, how can I take the contacts from the second for loop, and either find the contact that was created most recently, or create a list and sort by created date? The trick is that it will have to be specific to the parent, so most recent contact, for each account record.

 

I'm not sure how to go about this, any thoughts?

 

Thank you!

I'm trying to trigger a Lead Status change to 'Contacted' upon the completion of a task (email or phone call). Here's what I have setup in the Task Triggers, but it's not working. Can anyone see why this isn't working?

 

  trigger taskUpdateLeadStatus on Task (after update) {


    list<lead> liLeads = new list<lead>();
    list<id> liIds = new list<id>();
    
    for(Task sTask : trigger.new)
    {
        if(sTask.Status == 'Completed' && sTask.Subject == 'Call')
        {
            liIds.add(sTask.WhoId);
        }
    }
    
    for(Lead sLead : [select Id, Status from Lead where Id in : liIds])
    {
        sLead.Status = 'Contacted';
        liLeads.add(sLead);
    }
    
    update liLeads; 
    
}

I have seen a couple of these posts, but I'm still confused how to get my trigger to work. Here is my error:

 
OnPropLIUpdateIICopyFormulaValueToManual: execution of AfterInsert caused by: System.FinalException: Record is read-only Trigger.OnPropLIUpdateIICopyFormulaValueToManual: line 7, column 1
 
This is my trigger... any ideas??
 
trigger OnPropLIUpdateCopyFormulaValueToManual on Apttus_Proposal__Proposal_Line_Item__c (after update, after insert) {

 if (trigger.new.size()<>1) 
    return;
    //decimal installationTechServicesTotal = 0;
            if (trigger.new[0].Installation_Technical_Services__c != trigger.new[0].Installation_Tech_Ser_Formula__c){
              trigger.new[0].Installation_Technical_Services__c = trigger.new[0].Installation_Tech_Ser_Formula__c;
            }
    
}

Hi,

 

I created the custom button with value 'save', in an object,

 

After entering  the values in the all fields in the same object , how to change the status of the cutom button from 'save' to 'saved' when I click that 'save'?

 

 


Any help is appreciated .

 

Thanks,

Ambiga

Hi,

 

I have been working on a page to have a mass update of owner in Salesforce.com for Leads & Opportunities. 

Based on the input(csv file) from user the code is supposed to update the Lead & Opportunity object with appropriate Owners.

 

However, I m getting the following error when trying to update the owner information. 

 

 

 

System.DmlException: Update failed. First exception on row 0 with id 006Q000000BKaeIIAT; first error: INVALID_CROSS_REFERENCE_KEY, Owner ID: owner cannot be blank: [OwnerId]

 

Following is the method which is being called:

 

public Pagereference ReadFile()
{
nameFile=contentFile.toString();
filelines = nameFile.split('\n');
system.debug('file lines: '+filelines);
system.debug('file line size: '+filelines.size());
OpptyTaskTransfer_CTE o = new OpptyTaskTransfer_CTE();
opptytoupdate = new List<Opportunity>();
try
{

for (Integer i=1;i<filelines.size();i++)
{
List<String> inputvalues=filelines[i].split(',');
if(o.isValidId(inputvalues[0].trim()))
{
listOppty.add(inputvalues[0].trim());
listUser.add(inputvalues[1].trim());
mapOpptyOwner.put(inputvalues[1].trim(),inputvalues[0].trim());
}
else
{
ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'Please check the Lead Id: '+inputvalues[0].trim());
ApexPages.addMessage(errormsg);
}

}

Set<String> setUsers = new Set<String>();
setUsers.addAll(listUser);

for(String uname: setUsers)
{
if([select Id, Name,Username from User where username=:uname and isActive=true limit 1].size()!=1)
{
ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'Please check the Username: '+uname);
ApexPages.addMessage(errormsg);
}
}


allUsers = [select Id,Name,Username from User where Username IN: setUsers and isActive=true];

for (String username : setUsers)
{
for(User u : allUsers)
{
if(username ==u.Username)
{
mapUser.put(u.username,u.Id);
}
}
}

for(String uName : mapOpptyOwner.keySet())
{
mapOpptyOwnerId.put(mapOpptyOwner.get(uname),mapUser.get(uname));
}

allOppty = [select Id,OwnerId from Opportunity where Id IN: listOppty];

for(Id i : listOppty)
{
for(Opportunity op : allOppty)
{
if(i==op.Id)
{
op.OwnerId=mapOpptyOwnerId.get(i);
opptyToUpdate.add(op);
}
}
}

if(!opptytoupdate.isEmpty())
{
update opptytoupdate;
ApexPages.Message succmsg = new ApexPages.Message(ApexPages.severity.INFO,'Updated '+opptytoupdate.size()+' record(s) successfully.');
ApexPages.addMessage(succmsg);
}
}
catch (Exception e)
{
ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured. Please check the file uploaded or try again later');
ApexPages.addMessage(errormsg);
}
return null;
}

 

I am unable to figure out the issue here. Can some one please help?

 

Thanks...

Hey there,

 

I am very new to visualforce and writing any type of code in general and have come across a major snag. Basically, in my salesforce environment, Account is the main object and everything flows from the Account and is related somewhow. I have created a simple VF page with alot of help from one of the excercises within the VisualForce workbook. This visualforce page shows the  Account information as a tab labeled 'details' and all the other custom object/child objects/related lists are other tabs which appear on the page.

 

Now, different profiles have different object access, the main profile 'destiny standard'', does not have rights to alter or even view the Transaction object.The snag arose when I attempted to view an account from the Destiny Standard profile. I was greeted with an error message, something along the lines of "this profile does not have the rights to access this VF page". Easily solved by adding the visualforce page to the profile, however after adding it to the profile and attempting to access the Accounts object again i was greeted with "Transactions__r' is not a valid child relationship name for entity Account". I figured this was because I had labelled the transactions object as no access within the destiny standard profile.

 

My question: Is it possible to have a visualforce page, which will have sections that will not appear, should the user not have sufficient permission to access?

 

This is my accounts VF page:

 

<apex:page standardController="Account" showHeader="true"
tabStyle="account" >
<style>
.activeTab {background-color: #236FBD; color:white;
background-image:none}
.inactiveTab { background-color: lightgrey; color:black;
background-image:none}
</style>
<apex:tabPanel switchType="client" selectedTab="tabdetails"
id="AccountTabPanel" tabClass="activeTab"
inactiveTabClass="inactiveTab">
<apex:tab label="Details" name="AccDetails" id="tabdetails">
<apex:detail relatedList="false" title="true"/>
</apex:tab>
<apex:tab label="Contacts" name="Contacts" id="tabContact">
<apex:pageBlock title="Hello {!$User.FirstName}!">
You are displaying contacts from the {!account.name} account.
Click a contact's name to view his or her details.
</apex:pageBlock>
<apex:pageBlock title="Contacts">
<apex:form >
<apex:dataTable value="{!account.Contacts}" var="contact" cellPadding="4"
border="1">
<apex:column >
<apex:commandLink rerender="detail">
{!contact.Name}
<apex:param name="cid" value="{!contact.id}"/>
</apex:commandLink>
</apex:column>
</apex:dataTable>
</apex:form>
</apex:pageBlock>
<apex:outputPanel id="detail">
<apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false"
title="false"/>
</apex:outputPanel>
</apex:tab>
<apex:tab label="Destiny Products"
name="Destiny Products" id="tabDestinyProducts">
<apex:relatedList subject="{!account}"
list="Destiny_Products_and_Services__r" />
</apex:tab>
<apex:tab label="Destiny Services"
name="Destiny Services" id="tabDestinyServices">
<apex:relatedList subject="{!account}"
list="Services__r" />
</apex:tab>
<apex:tab label="Transactions"
name="Transactions" id="tabTransactions">
<apex:relatedList subject="{!account}"
list="Transactions__r" />
</apex:tab>
<apex:tab label="Activities" name="OpenActivities"
id="tabOpenAct">
<apex:relatedList subject="{!account}"
list="OpenActivities" />
<apex:relatedList subject="{!account}"
list="ActivityHistories" />
</apex:tab>
<apex:tab label="Compliance Notes"
name="Compliance Notes" id="tabComplianceNotes">
<apex:relatedList subject="{!account}"
list="Compliance_Notes__r" />
</apex:tab>
</apex:tabPanel>
</apex:page>

 

Any help I could get would be much appreciated. Thank you in advance.

 

Mikie

i want to get the "Role" on contact who created the task/Event.


how can i get that thru trigger/formula?

If I have a user input his/her email in VisualForce, and after verifying the user exists, how do I use the email address to retrieve the user’s phone number or other info?

Can someone please give me an example or a URL,

 

Thanks

Hi when i am upload a csv to create Account and contact using Apex code. In the contact i need to give the acoount name which is a list. How to get accoutn id to contact.In the code i have bold the line contac.Kindly anyone tell how to resolve this.

 

My code:

 

accstoupload = new List<Account>();
contoupload = new List<Contact>();
opptoupload = new List<Opportunity>();
for (Integer i=1;i<filelines.size();i++)
{
String[] inputvalues = new String[]{};
inputvalues = filelines[i].split(',');

Account a = new Account();
a.Name = inputvalues[0];

accstoupload.add(a);
}

for (Integer i=1;i<filelines.size();i++)
{
String[] inputconvalues = new String[]{};
inputconvalues = filelines[i].split(',');

Contact con = new Contact();
 con.AccountId = a.Id;
con.Lastname = inputconvalues[1];
con.Lastname_lead__c = inputconvalues[2];


contoupload.add(con);
}

Hello,

I want to know how to write a relational soql query between contact and campaignmember. 

I need to display list of contact details having relationship with campaign member.

 

Thank you.

Hi

 

I have two objects A and B 

B has MasterDetail relationship with A

how can I  write a trigger to insert a record In object B on update of field in a record of  object A, i need to make the sum of some fields in each object created in A

 

 

 

Thanks in advance

Hi,

 

I have created a trigger in task where the creator should recieve an email alert when the task is completed.Here the trigger is working fine.Creator has received the emailalert .But in emailalert  i need to display opportunity name which is related to that task. Here i used WhatId. How do i get opportunity name instead of opportunity id

 

trigger EmailAlertforTaskCompletion on Task (before update) {
    
    set<String> setownerIds = new set<String>();
    if(Trigger.isUpdate && Trigger.isBefore){
        for(Task objT : Trigger.new){
            if(objT.Status == 'Completed'&& ('' + objT.WhatId).startsWith('006')){
                setownerIds.add(objT.CreatedById);
                
       List<User> lstU = [select id,email from User where Id in : setownerIds];  // limit 1      
       List<String> lstEmails = new List<String>();
       
       for(User objU : lstU){
           lstEmails.add(objU.email);
       }
       
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        List<String> toAddresses = new List<String>();
        toAddresses.addall(lstEmails);
        mail.setToAddresses(toAddresses);
        mail.setSubject('A task assigned by you has Completed');    // Set the subject
                
        String template = 'Hello, \nYour assigned task has Completed. Here are the details - \n\n';
        template+= 'Subject - {0}\n';
        template+= 'Opportunity - {1}\n';
        template+= 'Due Date - {2}\n';
        template+= 'Priority - {3}\n';
        template+= 'Comments - {4}\n';
        
        String duedate = '';
        if (objT.ActivityDate==null)
            duedate = '';
        else
            duedate = objT.ActivityDate.format();
            
        List<String> args = new List<String>();
        
        args.add(objT.Subject);
        args.add(objT.WhatId);
        args.add(duedate);
        args.add(objT.Priority);
        args.add(objT.Description);
       
        String formattedHtml = String.format(template, args);
       
        mail.setPlainTextBody(formattedHtml);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
       }
     }
    }
}

 

 

 

  • November 30, 2012
  • Like
  • 0

I am relatively new to apex.  I have written a couple of apex triggers, but never one that runs before something is inserted.  I am not sure on a couple of things.  here is my code:

    if(trigger.isinsert){
        list<Object1__c> field1List = new list<Object1__c>();
        Object1__c m = new Object1__c();
        for(Object1__c t : trigger.new){
            m.Field1__c = t.Field1__c;
            m.Field1_email__c = t.Field1__c;
            field1List.add(m);
    }    }

 What I am trying to do is copy the data in Field1__c to Field1_email__c.  What I am not sure and maybe I am just complicating it is how to add the change back to the items that triggered the code and make sure that all of the fields are inserted not just the 2 that I am working with.  If I just add "insert field1List;" will it add the data to salesforce and if so will it add the other fields that are initially on the object like field2__c, field3__c and so forth?  

Hi,

 

I have two objects Test1,Test2.(Lookup relation)

The two objects have amount fields..

I want to count the child object record filed into parent...

 

Please help me....

Hi,

 

Need help on following.

 

I have a html email template with some text, letter head and ahave inserted a image(populated this using the greenish buttonavailable when we edit the html email template).

 

Initially everything was fine but suddenly the image is not visible now and can only see a box with cross red mark.

 

The image is stored in documents. The image stored in document is marked "for external use" so that is not the issue.

 

Someones input on this would greatly help me out.

 

Thanks,

Cloud Force.

Hai all
Can any one tell me how to use java script in visual force page by using static resources 
Hi,

We have the following, pls let me know how to solve it:
There are 3 record types for Case, say A,B and C.
If an User creates a Case record with record type A then restrict the User to View/Edit only Case records(his/others) of record type A only.
If an User creates a Case record with record type B then restrict the User to View/Edit only Case records(his/others) of record type B only.
How can it be done, pls let us know the solution as it is bit urgent.

Thanks a lot.
Hi All,

i am geting this error when i attch an image to master object (in file and attchments) and the detail object have records.i am also updating master object when a new detail record is added and approved. 
it seems that adding an image trigers the loop.

Error: Apex trigger trgOrphanImage caused an unexpected exception, contact your administrator: trgOrphanImage: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id a0H2000000A5UtqEAF; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, trgAnnualProgressReportIns: execution of AfterUpdate caused by: System.ListException: Duplicate id in list: a0A2000000KkOr2EAF Class.AnnualReportUpdBiodata.updBiodata: line 96, column 1 Trigger.trgAnnualProgressReportIns: line 49, column 1: []: Trigger.trgOrphanImage: line 59, column 1

 
Create fieldset on Contact Object and render them based on the criteria in visualforce,Please give me best example??
I need help with a controller extension to retrieve and update parent records from a list view. We have a child object called Patient_Session__c that has a lookup to parent called Patient_c and want to use a visualforce page to update the parent records in mass edit mode from a list view of the child records.  Here's the extension I am using:

public with sharing class updatePatientInfo {
    public Patient_Session__c pgn;
    public Patient__c patient;

    public updatePatientInfo(ApexPages.StandardController controller) {
        this.pgn = (Patient_Session__c)controller.getRecord();
        this.patient = [SELECT Id,Name,Patient_Description__c,A_1__c,A_Frequency__c,B_1__c,B1_Frequency__c,B2_Frequency__c,C_1__c,C1_Frequency__c,C2_Frequency__c,D_1__c,D1_Frequency__c,D2_Frequency__c,X__c FROM Patient__c WHERE ID = :ApexPages.currentPage().getParameters().get('id')];
    }

    public PageReference saveRecord() {
        
    update patient;
    update pgn;  
        return null;
    }
 }

Here's the visualforcepage

<apex:page controller="updatePatientInfo" tabStyle="Patient_Session__c" sidebar="false">
<pbe:PageBlockTableEnhancerADV targetPbTableIds="details," paginate="true" defaultPageSize="100" pageSizeOptions="5,10,20,30,40,50,100" />
  <style type="text/css">
        .myClass { width: 300px; }
    </style>
<h1>Mass Edit Patients</h1>
<apex:form >
    <apex:pageblock >
    <apex:pagemessages />
       <apex:pageBlockButtons >        
        <apex:commandButton value="Quick Save" action="{!quicksave}"/>
        <apex:commandButton value="Save" action="{!save}"/>
        <apex:commandButton value="Cancel" action="{!cancel}"/>
    </apex:pageBlockButtons>
    <apex:pageBlockSection title="Details" columns="1">
    <apex:pageBlockTable value="{!selected}" var="pgn" id="details">
        <apex:column headervalue="First Name">
            <apex:inputField value="{!pgn.Patient__r.Patient_Description__c}"/>
        </apex:column>
            </apex:pageBlockTable>
            </apex:pageBlockSection>   
        </apex:pageBlock>
    </apex:form>        
</apex:page>

When I try to save the visualforce page I get this error
 "Error: Unknown constructor 'updatePatientInfo.updatePatientInfo()"

I am new to apex so any help would be greatly appreciated
I have created a page that displays opportunities across related accounts and I would like to allow users to create a new opportunity associated to one of those accounts directly from the page. Because I have a search function on the page as well, my form has multiple functions based on the action button used. If I simply added input fields for an Opportunity object, the field requirements (name, close date, etc.) would cause errors when searching. To resolve this I have created a custom Opportunity-like object (tOpp__c) without required fields and then I build a new Opportunity object in Apex. The problem I am running into is passing the selected option from a selectList into the controller so that I can populate fields on the Opportunity that require a lookup (Account, Owner, etc.) single-value input fields are passing data fine and the HTML output of the page appears to show the selected list populated correctly, but I get a null value in my debug logs for the selectList variable.

PAGE:
...
                 <apex:column headerValue="Account Name">
                     <apex:selectList size="1" value="{!tOpp.Account__c}">
                             <apex:selectOptions value="{!orgAcctOpts}"/>
                      </apex:selectList>
                 </apex:column>
...
                 <apex:column headerValue="">
                     <apex:commandButton value="Create" action="{!doCreateOpp}" rerender="all"/>
                 </apex:column>
...

CONTROLLER:

    public PageReference doCreateOpp() {
        System.Debug('Create Opportunity');
        for (tOpp__c tOpp : tOpps) {
            System.Debug('Starting Opportunity Insert: '+tOpp.Account__c);
            List<Account> accts = [select Id from Account where Name = :(tOpp.Account__c) limit 1];
            if (!accts.isEmpty()) {
                System.Debug('Account: '+accts.get(0));           
                Opportunity o = new Opportunity();
                o.Name = tOpp.Name;
                o.StageName = tOpp.StageName__c;
                o.CloseDate = System.today();
                o.Account = [select Id from Account where Name = :(tOpp.Account__c)];
                o.Owner = [select Id from User where Name = :(tOpp.Owner__c)];
                insert o;
            } else {
                System.Debug('Account Not Found: '+tOpp.Account__c);            
            }
        }
        return null;
    }

HTML:

...
       <td class=" dataCell  " id="summary_:form_:detail_:newopp_:0:j_id36" colspan="1">
            <select name="summary_:form_:detail_:newopp_:0:j_id37" size="1">    <option value="001m0000007HwqeAAC">Test1</option>
                <option value="001m0000007HwqyAAC">Test3</option>
                <option value="001m0000007HwrNAAS">Test5</option>
                <option value="001m0000007HwrDAAS">Test4</option>
                <option value="001m0000007HwqjAAC">Test2</option>
            </select></td>
...

DEBUG:

13:57:50.038 (38447582)|USER_DEBUG|[115]|DEBUG|Create Opportunities
13:57:50.038 (38455535)|SYSTEM_METHOD_EXIT|[115]|System.debug(ANY)
13:57:50.038 (38552803)|SYSTEM_METHOD_ENTRY|[116]|LIST<tOpp__c>.iterator()
13:57:50.038 (38745006)|SYSTEM_METHOD_EXIT|[116]|LIST<tOpp__c>.iterator()
13:57:50.038 (38777135)|SYSTEM_METHOD_ENTRY|[116]|system.ListIterator.hasNext()
13:57:50.038 (38792964)|SYSTEM_METHOD_EXIT|[116]|system.ListIterator.hasNext()
13:57:50.038 (38844991)|SYSTEM_METHOD_ENTRY|[117]|System.debug(ANY)
13:57:50.038 (38865250)|USER_DEBUG|[117]|DEBUG|tOpp.Account__c: null
13:57:50.038 (38872097)|SYSTEM_METHOD_EXIT|[117]|System.debug(ANY)
13:57:50.038 (38887525)|SYSTEM_METHOD_ENTRY|[118]|System.debug(ANY)
13:57:50.038 (38901300)|USER_DEBUG|[118]|DEBUG|Starting Opportunity Insert: null
13:57:50.038 (38907485)|SYSTEM_METHOD_EXIT|[118]|System.debug(ANY)
13:57:50.039 (39440025)|SOQL_EXECUTE_BEGIN|[119]|Aggregations:0|select Id from Account where Name = :tmpVar1 limit 1
13:57:50.042 (42866602)|SOQL_EXECUTE_END|[119]|Rows:0
13:57:50.042 (42983278)|SYSTEM_METHOD_ENTRY|[120]|LIST<Account>.isEmpty()
13:57:50.043 (43010277)|SYSTEM_METHOD_EXIT|[120]|LIST<Account>.isEmpty()
13:57:50.043 (43036387)|SYSTEM_METHOD_ENTRY|[131]|System.debug(ANY)
13:57:50.043 (43055532)|USER_DEBUG|[131]|DEBUG|Account Not Found:null
 
I have a Vfp with standard controller="Single_Topic__KAV" and controller extension="Feedbackctrl".
There is a custom checkbox field in Single_Topic__KAV, i want that field value in controller.

In VFP:
i can get the checkbox field by:
<apex:outputfield value="Single_Topic__KAV.Preview_Flag__c"/>

i need the field value to use in controller for:
If(Preview_Flag__c==false){---------------------------}
else{---------------------}
else{--------------------------------}
Do we know of any getting started or how to use material on SAQL ? Its Dev guide everything except how to use it :)

Hi all,

came up with a doubt,can i combine two different standard objects into single LIST

ie

List<contact> listname =  List<contact>;
List<campaignmember> listname =  List<campaignmember>;

i need to combine above two List into single one may be like (contact.campaignmember.date,contact.campaignmember.name)

i wrote a wrapper where i have access to those two list of data.now just need to combine  and return them as list ,is that possible ??.

please post possible ideas to do that.

 

Thanks
D Naveen Rahul.

Hi..
  Please Explain About Set And get Methods IN simple way..
   "Get" and "Set" Methods How thes work  ::
        1- Visual Force -To- Class(console).
        2-Console(Class) -To- VisualForce
Hi all, 

Okay so I'm pretty weak at using sub query and usually avoid this. So I will need a little help on this. 
 
List<Job__c> jobs = [SELECT ID, Contact__c, Project_site_contact_name__c, (SELECT ID, Contact__c FROM Job_Contacts__r) FROM Job__c WHERE ID in :updateContactIds];
	for (Job__c job : jobs)
	{		

		for(Contact con : jobs.job_contacts__r)
		{

                }
        {
So here's the little code snippet. I the 2nd for loop is giving me error saying "Initial term of field expression must be a concrete SObject: LIST&lt;Job__c&gt;"

If I understand correctly the error is saying Job.job_contact__c is not a list. How do I check through the sub query? 
Hi All,
   I have a requirement that when i calculate Net Amount=total=vat that after calculation this i have to fetch that formula field in my parent object so how can i fetch that field using Roll up Summary.
Thanks,
Sam
Hi frnds,

I have n  number of GrandParentAccount and their related Parent Accounts and their child accounts.

AccountName        parentAccountlookupfield    RecordType
GPACC - GP1          null                                     Test1
PACC - P1               GP1                                    Test1
CACC - C1               P1                                     anything

Based on Record type(if record type is same for both parent and grandparent) I need to change the child account's parent name as GranparentName.(For C1, i need to update parent account as GP1 instead of P1)
I need write schedulable apex for following prob..

I have contacts and Accounts standard object and one custom object attendance

Now for account-X there are two contact roles ->p and q-->

and Attendence is child object of contacts--

So for contact-->P -there are two attendence records wit status(data)-->1.payable and 2.Nonpayble


So for contact-->q there are two attendence records wit status(data)-->1.payable and 2.Nonpayble

Now I need write apex code to create a opportunity for this account X-
And I want add products to this opportunity

But I have already two products-Payable and Non payable with standard price

So for this opportunity i need to add this products accourding to the attendence records count of contact..

Ex:For X account opportunity---> there will be 4 produts(2-payable n 2-non payable)

Now I need apex code which will automaticaly create this opportunity and add products to it according to the contact attendence record.

and I want run this code once in a month..using scedule apex;

I think this very difficult , I am tring it from a weak...

Please help me to write this code..Even any reffence will also help me lot..
Hi.

I have a custom object (TargetX_SRMb__Application__c) It has a relationship to Contact defined in WSDL by:

  <complexType name="TargetX_SRMb__Application__c">
                <complexContent>
                    <extension base="ens:sObject">

...
                       <element name="TargetX_SRMb__Contact__c" nillable="true" minOccurs="0" type="tns:ID"/>
                        <element name="TargetX_SRMb__Contact__r" nillable="true" minOccurs="0" type="ens:Contact"/>

However, when I run SOQL test as:

 Contact contact = [SELECT  c.Id, c.lastName, (Select CreatedDate  FROM TargetX_SRMb__Contact__r) FROM Contact c]

I get error:

Error: Compile Error: Didn't understand relationship 'TargetX_SRMb__Contact__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name

I also tries adding a "s" as follows: Same error.

 Contact contact = [SELECT  c.Id, c.lastName, (Select CreatedDate  FROM TargetX_SRMb__Contacts__r) FROM Contact c]

 Is this not the correct syntax to query child records from a custom object?

Thanks in advance,

Jon
Hi,

I have defined Apex triggers on after insert which will fire the email on per case basis. Issue is same email is firing twice. Could any one help to get it solve..

trigger sendEmail on Case (after insert,after update) {
    Public static Boolean InitialEmail =false;
  
     for(Case c:trigger.new) {
       
        system.debug('outside'+c.Send_Email_to_Contact__c);
       
        if ((trigger.isInsert || (trigger.oldMap.get(c.Id).Send_Email_to_Contact__c != c.Send_Email_to_Contact__c)) && (c.Send_Email_to_Contact__c && !c.Do_not_Send_Email__c  && c.Email_of_Complainant__c!=null && c.Status!='Completed')) {
               
                system.debug('??????'+c.Send_Email_to_Contact__c);
              
                    sendEmailMessage(c.id,c.ownerId,c.Internal_Comments__c,c.Email_of_Complainant__c,c.Site_Details__c,c.CaseNumber,c.Case_Customer_Reference__c );
        }
       
}       
       
       
Hello all,

I'm starting to develop for Sales Force, so everything here is kind of new to me.

I've already followed the following developer workbooks:
- Force.Com Workbook
- Force.com Integration Workbook

I now need to start researching on how to implement the specific needs of my client. The problem is I do not know where to start and need some guidance on the first steps.
The two features I need to implement are:

1. Textbox in the top bar
I need to place a new textbox on the top bar that is always visible, somewhere to the right of the existing Search box.
This textbox will fire requests to an external application and redirect to a custom made results page in Sales force.

2. User as bot in chat
I would like to create a new user, let's call him "Adam". Whenever another user "talks" with "Adam" I would like to fire a request to an external application and return the result as Adam's response.
If this is not possible, a workaround would be to create a new control that would sit next to the Chat in the bottom right corner of the page. This control would be called "Adam" and would be similar to the existing Chat but would request information from our external application.

Any suggestions on how to implement these features? Any documents, forum posts, or bits of information that can get me started would be appreciated.

Thanks in advance for your help.

Kindly
Eduardo Poças
hi, how can i calculate next working day excluding public holiday configured in my saleforce org & weekend using formula field?

can anyone share me the formula?
In Leads Page, I want to have  a Sales Score Text field (formula field ), which needs to be updated by first checking the campaign field is empty or not and has to update the Sales Score field based on other Campaign Score field (Number field).

Is this is possible with Formula fields, if so how ...

Please clarrify..
Hi all, 

I have created one visualforce page. In that There is a picklist component with many values inside.
Now whenever i run that visualforce page on google chrome(Version 32.0.1700.76 m) at that time i
can't able to pull down the scroll bar using mouse first click. can you please help me over this?