• Eugene Pozniak
  • NEWBIE
  • 175 Points
  • Member since 2012

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 23
    Replies

Hi,

 

I am using a visualforce page in my project which also display some error messages to the users. I want to know if it is possible to change the text of the error message based on the current user's locale. Can we leverage the translational workbench for this? I'm guessing that

 

All inputs are welcome.

 

Thanks,

 

Jerun Jose

 

Hi,

 

Can some one give an example of how to populate data in to:

 

Map<Id,List<Id>>

 

Here Id is UserRoleId and List<Id> is the List of users who belong to that role id.

 

Thanks,

JBabu.

  • May 31, 2012
  • Like
  • 0

Hi am creating a trigger on child object it will fire on account(parent) when am insert a record in child at 

 

address__c field that text will update in this parent account in billing city.

 

is it correct this code please help me am getting an Error : Error: "Compile Error: Initial term of field expression must be

 

a concrete SObject: String at line 17 column 23"

 

 

 

trigger updatingaccount on Work_flow__c (after insert,after update)
{
set<id> xyzset=new set<id>();
for(work_flow__c c:trigger.new)
{
if(c.address__c == null || c.address__c != null)
{
xyzset.add(c.account__c);
}
}
map<id,string> app=new map<id,string>();
for(account a:[select id,Billingcity from account where id in:xyzset limit 50000])
app.put(a.id,a.Billingcity);
for(work_flow__c c:trigger.new)
{
if(c.address__c == null || c.address__c != null)
app.get(c.account__c).Billingcity = c.address__c;
}
}

hi

i have a controller like

 

public with sharing class assignment5
{
    public string name{get;set;}
    public assignment5(ApexPages.StandardSetController controller)
     {

      }
    
    public void selected_name()
    {
             //name.fontstyle='bold';      
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.info, 'you selected  '+name);
            Apexpages.addMessage(mymsg);
    }
}

 

page:-

<apex:page standardController="account" recordSetVar="acc" >
    
    <apex:form id="f1">
       <apex:sectionHeader title="Assighment 5"/>
        <apex:pageBlock >
          <apex:pageMessages ></apex:pageMessages>
            <apex:pageBlockTable value="{!acc}" var="a" >
            <apex:column headerValue="Name" id="col1">
                <apex:commandLink action="{!selected_name}" reRender="f1" >
                    {!a.name}
                    <apex:param value="{!a.name}" name="n"  assignTo="{!name}"/>
                </apex:commandlink>
            </apex:column>
            <apex:column value="{!a.BillingState}" id="col2" />
            <apex:column value="{!a.phone}" id="col3" />
            <apex:column value="{!a.website}" id="col4"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

in vf page the font style of   "name" should be in bold.

ex: you selected  xxxxx

I'm trying to grab all the notes for every contact associated with an account. I built a controller to do it:

 

public class aggregateNotes{
    private Opportunity opp;
    public aggregateNotes(ApexPages.StandardController controller) {
        this.opp = (Opportunity)controller.getRecord();
    }
    
    // container for the notes (not used, yet)
    public class row {
        public string LastName {get; set;}
        public string Body {get; set;}
        public row(sObject o){
            LastName = (String)o.get('LastName');
            Body = (String)o.get('Body');
        }        
    }
    
    public List<row> getRelatedNotes(){
        // get the account id from the opportunity
        opp = [SELECT id, Account.id FROM Opportunity WHERE id = :opp.id];
        
        List<row> rows = new List<row>();
        for(sObject o : [SELECT LastName, (SELECT Body FROM Notes) FROM Contact WHERE Account.Id = :opp.Account.id]){
            // this fails! WTF?
            System.debug(o.get('Body'));
        }
        
        return rows;
    }
}

 

I get a "System.SObjectException: Invalid field Body for Contact" on the System.debug(o.get('Body')) call. How do I access the body field in that SOQL?


  • May 25, 2012
  • Like
  • 0

Hi guys,

 

I'm a newbee to Apex coding and I'm not long in my new role working on Salesforce admin and development. I'm just wondering if any of you kind people can help me with my following scenario.

 

I have 2 objects and I'm trying to figure out a way to perform a check (from Object A) on the status of a number of instances of the other object (Object B). Basically what I need to setup is a check that will change the status of Object A to complete, once the statuses of all instances of Object B are marked as complete.

 

My 2 objects are related through a lookup field that is on Object B, and it is a lookup field for Object A.

 

I hope my query makes sense. If any of you can provide me with some pointers on how to achieve what I'm looking for I would be very grateful.

 

Many thanks in advance for your help with this!

Hi,

 

I am using a visualforce page in my project which also display some error messages to the users. I want to know if it is possible to change the text of the error message based on the current user's locale. Can we leverage the translational workbench for this? I'm guessing that

 

All inputs are welcome.

 

Thanks,

 

Jerun Jose

 

Hi,

 

I am working on a visualforce page which is used to integrate SFDC data with an external system.

The integration process involves multiple callouts (about 5) which can take up a lot of time. Is it possible to update the visualforce page to display the status of the transaction?

 

Say if the method which is called from the page is

public someReturn someMethod(){
	method1();
	// say status is s1
	method2();
	// say status is s2
	method3();
	// say status is s3
	method4();
	// say status is s4
	method5();
	// say status is s5
}

 How can we display the status of the method 'someMethod' to update the page with the statuses s1, s2 ..

 

Any suggestions are welcome.

 

Thanks,

 

Jerun Jose

I am writing a Visualforce page to show commission payments for our company's sales reps.  The commissions have gotten more complicated as we implemented a team/pod environment.  At a high level, this means some sales reps may earn commissions on opportunities owned by other reps on their team, and the commission split varies by opportunity record type.  This appeared to be too complicated to accomplish in a standard report, and developing a simple Visualforce page seemed like an alternative solution.

 

My approach for the page is to have a string list with all of the sales rep names.  In the future, this may be queried dynamically, for the moment it is hard coded.  Then I want to display a table showing the opportunities each rep has closed in the pay period.  I chose to use apex:repeat to iterate through the list of sales reps.  In each iteration, I passed the apex:repeat var to a method to query for opportunities owned by that rep.  The problem I'm encountering is that when the var is passed into the method, the method does not see the var value, it shows up as blank.  Why is this, and is there a workaround?

 

I also realized that running a new opportunity query for each sales rep is inefficient, so another approach would be to run one query at the start for all opportunities, then in the method just filter the list of opps down to those that are applicable to each rep.  I tried this as well, but ran into the same problem - the var value will not pass into the method, so I have no way to use it to filter the list of opps to just that rep.

 

Note that due to the team/pod structure, some reps will get paid partial commissions on opportunities owned by other reps.  I was going to add extra logic for this once I got the basic page working.  This complexity prevents me from doing a simple single list/query and just grouping the opps by the owner - this will not work with the extra complexity needed.

 

What am I missing here?  Can anyone offer a suggestion for how to fix this or to take a different approach?  Here is my code:

 

<apex:page controller="CommissionCalc">
<br></br>  
    <apex:pageBlock title="Commissions">

        <apex:form >
        <apex:actionFunction name="updateResults" action="{!updateResults}" rerender="Results"/>
        <apex:outputLabel value="Pay Date: " /> 
        <apex:selectlist value="{!dateRange}" multiselect="false" size="1" onChange="updateResults();">
            <apex:selectOption itemValue="" itemLabel="Select Date"/>
            <apex:selectOption itemValue="2012-01-16" itemLabel="Jan 16 2012"/>
            <apex:selectOption itemValue="2012-01-31" itemLabel="Jan 31 2012"/>
            <apex:selectOption itemValue="2012-02-15" itemLabel="Feb 15 2012"/>
            <apex:selectOption itemValue="2012-02-28" itemLabel="Feb 28 2012"/>
        </apex:selectlist>      
        </apex:form>
        
        <apex:outputPanel id="Results">

        <apex:repeat value="{!repNames}" var="repName"/>
            <br/><apex:outputText value="{!repName}"/><br/>

        <apex:pageBlockTable value="{!opps}" var="o">
            <apex:column value="{!o.Name}"/>
            <apex:column value="{!o.OwnerId}"/>
            <apex:column value="{!o.CloseDate}"/>
            <apex:column headerValue="Opportunity Amount" value="{!o.Amount}"/>               
        </apex:pageBlockTable>
        </apex:repeat>
        </apex:outputPanel>

    </apex:pageBlock>
</apex:page>

 

Controller:

 

public class CommissionCalc {
    List<Opportunity> opps;
    public String dateRange;
    public String repName;
    List<String> repNames = new String[] {'00570000001b7UQ','00570000001ZelI','00570000001a42K'};

    
    public List<Opportunity> getOpps(){
        if(dateRange == null ) { return null; } else {     
        opps = [select Id, Name, Amount, CloseDate, OwnerId, Pay_Period__c from Opportunity where OwnerId = :repName and StageName = 'Closed Won' and Pay_Period__c = :dateRange];

// QUERY ABOVE IS WHAT DOES NOT WORK - REPNAME VAR COMES IN AS NULL, EVEN THOUGH IT HAS A VALUE IN THE PAGE ITSELF

return opps; } } public List<String> getRepNames() { return repNames; } public String getDateRange() { return dateRange; } public void setDateRange(String s) { dateRange = s; } public Pagereference updateResults() { getOpps();
return opps; } }

 

 

 

 

 

 

 

  • June 05, 2012
  • Like
  • 0

I  two lists  list a and  list b

i am able to display a table like this

 

Column1   Column2

a,b,c             e,f,h

 

where a,b,c are contents of list a and e,f,h are contents of list b

How do i make it to

Column1   Column2

a                      e

b                        f

c                        h

 

 

This is a long stanging requiement of mine with<ape:columns>

 

Regards

Punnoose

I have some tests running for a Trigger (before insert), where I set some lookup fields (based on some logic from other fields).

 

Through debugging, I can see that the fields are set properly within my Trigger (let's call this field LookupField__c).

 

However, in my test class, if I query the inserted records [select Id, LookupField__c from Sobject where Id = :insertedRecord.Id], the LookupField__c is null (even though in the Trigger, I can see it was set).

 

The field is not touched anywhere else.  Is there a reason I can't query on this in the Test Class?  I could have sworn I used to be able to do this.

 

how to build empty table in vf & need to insert values into that table (manually)

Hello,

 

I have a VF page with a button that should be hidden while the Id of its parent record is null (meaning until the Save buton higher up in the page is clicked and a save method is executed which will persist the object in the DB. At that point I want to have the button farther down (which creates instances of child records to appear again so that releated items can be added.  See the code below:

 

This is at the top of the page where a save buton is placed to execute the saving of the Sales Order (parent object)

 

<apex:pageblockButtons >
<apex:commandButton action="{!saveSO}" value="Save Changes" reRender="out,btnAddSOI" status="saveStatus">
</apex:commandButton>

  then at the bottom of the page in another pageblock I have the following:

 

    <apex:pageBlockButtons >
    <apex:outputPanel id="btnAddSOI" rendered="{!SOsaved}">
       <apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="tablePnl"  />
    </apex:outputPanel>
    </apex:pageBlockButtons>

 This is the button that should dissapear if the parent record has not been saved yet and should magically reapear once the button has been saved. Currently on page load the visibility reflect correctly(e.g. if editing an existing record via the VF page then the button is visible, else if its a new record via the same VF page then the button is hidden) The problem lies in that the button doesn't REAPPEAR once the record is saved.  Below is the controller method in use (SOsaved):

 

    public Boolean SOsaved {
        get { 
        boolean bool;
        bool= so.Id <> null ? True : False;
        System.debug('SO saved ' + bool + ' - ' + so.Id);
        return bool;
        }
    }

 Can someone please assist???

Hi Guys,

 

I have scenario like this, I have to display all the contacts related Accounts in visual force page.

 How to write th Apex class for this.

 

Thanks,

Shaik

  • June 01, 2012
  • Like
  • 0

hi

i am trying to save a new child record on a vf page. i want that the master detail field of the record is filled automatically with the parent id passed in the url of the page. can anyone help me with this plz...

Hi,

 

Can some one give an example of how to populate data in to:

 

Map<Id,List<Id>>

 

Here Id is UserRoleId and List<Id> is the List of users who belong to that role id.

 

Thanks,

JBabu.

  • May 31, 2012
  • Like
  • 0

Hi,

 

I want to know how i can open another visualforce page from a visualforce page by the use of button.

The first visualforce page i am using i am adding a contact to database which will have a unique id. when i add the user to the database it should open another visualforce to show the details i have added to the database.

 

Thank You

HI,

 

Need help with insering the Oppline Item. There are lot of discussions in this board about this and i even followed them but still couldnt insert the Opportunity Line Item The error i get is 

 

FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId (pricebook entry is in a different pricebook than the one assigned to the opportunity): [PricebookEntryId]

 

Pricebook2 pb= [select Id from PriceBook2 where IsStandard=True limit 1];


Product2 product = new Product2();
product.Name='Test Product';
product.IsActive=true;
insert product ;

// Create a pricebook entry for custom pricebook
PricebookEntry pbe = new PricebookEntry();
pbe.UseStandardPrice = false;
pbe.Pricebook2Id=pb.id;
pbe.Product2Id=product.id;
pbe.IsActive=true;
pbe.UnitPrice=99;

insert pbe;

 

Opportunity objOpp1= new Opportunity();
objOpp1.Name = 'Testing12';
 objOpp1.StageName = 'Upside';
 objOpp1.CloseDate = System.Today();
 insert objOpp1;


OpportunityLineItem NewRec = new OpportunityLineItem();
NewRec.TotalPrice=99;
NewRec.Quantity=1;
NewRec.OpportunityId=objOpp1.Id;
NewRec.PricebookEntryId=pbe.id;
insert NewRec;

 

Thanks

Hi all

 

I'm looking for a way to create a trigger on a pricebook entry that will run some logic each time a Product's price changes.

The problem is that as far as I can see there is no why to write a trigger on procebook and procebookentry.

 

Am I correct in assuming this type of triggered is not possible?

 

Any advise what is the right way to make this work is appreciated.

 

Thanks

 

 

  • May 31, 2012
  • Like
  • 0

Hi am creating a trigger on child object it will fire on account(parent) when am insert a record in child at 

 

address__c field that text will update in this parent account in billing city.

 

is it correct this code please help me am getting an Error : Error: "Compile Error: Initial term of field expression must be

 

a concrete SObject: String at line 17 column 23"

 

 

 

trigger updatingaccount on Work_flow__c (after insert,after update)
{
set<id> xyzset=new set<id>();
for(work_flow__c c:trigger.new)
{
if(c.address__c == null || c.address__c != null)
{
xyzset.add(c.account__c);
}
}
map<id,string> app=new map<id,string>();
for(account a:[select id,Billingcity from account where id in:xyzset limit 50000])
app.put(a.id,a.Billingcity);
for(work_flow__c c:trigger.new)
{
if(c.address__c == null || c.address__c != null)
app.get(c.account__c).Billingcity = c.address__c;
}
}

In lead We have a standard field name "Description" and opportunity also have same standard field.

 

so is it possible that we map these two fields.

 

thanks in advance.