• Ravi Rao Arrabelli
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 8
    Replies
Hi All,
I'm building a custom search, in which multi-select is one of the filter criteria. I have built the following code and used dynamic soql for this purpose:

vf page code:
<apex:selectlist multiselect="True" size="4" value="{!businessLines}" >
         <apex:selectOptions value="{!busLinesLs}" />
 </apex:selectlist>

Custom Controller Code:
public List<string> businessLines{get;set;}
public List<SelectOption> busLinesLs{
        get{
            if(busLinesLs==null){
            busLinesLs = new List<SelectOption>();    
                Schema.DescribeFieldResult field = CustomObj__c.CustomField__c.getDescribe();
                for (Schema.PickListEntry f: field.getPickListValues())
                    busLinesLs.add(new SelectOption(f.getValue(),f.getLabel()));
            }
            return busLinesLs;
        }
        set;
    }

 if(!businessLines.isempty()){
            boolean flag = False;
            system.debug('----------'+ businessLines);
            soqlStr += 'AND (';
            for(String str: businessLines){
                if(flag){
                    soqlStr += ' OR ';
                }
                soqlStr += ' CustomField__c INCLUDES (\''+str+'\')';
                flag = True;
            }
            soqlStr += ')';
        }

I'm able to populate the picklist values in the page, but I think the highlighted values are not getting passed back to the controller. Can someone, please help me.
Thanks in Advance.
Hi All,
I'm building a custom search, in which multi-select is one of the filter criteria. I have built the following code and used dynamic soql for this purpose:

vf page code:
<apex:selectlist multiselect="True" size="4" value="{!businessLines}" >
         <apex:selectOptions value="{!busLinesLs}" />
 </apex:selectlist>

Custom Controller Code:
public List<string> businessLines{get;set;}
public List<SelectOption> busLinesLs{
        get{
            if(busLinesLs==null){
            busLinesLs = new List<SelectOption>();    
                Schema.DescribeFieldResult field = CustomObj__c.CustomField__c.getDescribe();
                for (Schema.PickListEntry f: field.getPickListValues())
                    busLinesLs.add(new SelectOption(f.getValue(),f.getLabel()));
            }
            return busLinesLs;
        }
        set;
    }

 if(!businessLines.isempty()){
            boolean flag = False;
            system.debug('----------'+ businessLines);
            soqlStr += 'AND (';
            for(String str: businessLines){
                if(flag){
                    soqlStr += ' OR ';
                }
                soqlStr += ' CustomField__c INCLUDES (\''+str+'\')';
                flag = True;
            }
            soqlStr += ')';
        }

I'm able to populate the picklist values in the page, but I think the highlighted values are not getting passed back to the controller. Can someone, please help me.
Thanks in Advance.

Hi everyone,

i'm getting the following error after the system checks the challenge:

"Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.QueryException: List has no rows for assignment to SObject"

I already tested it via Apex and via REST Explorer in Workbench, the code seems fine to me:

@restResource(urlMapping='/Account/*/contacts')
global class AccountManager {
	
    @httpGet
    global static Account getAccount(){
        RestRequest request = RestContext.request;
        String accountId = request.requestURI.substringBetween('/Account/' , '/contacts');
        
        Account result = [SELECT Id, Name, (SELECT Id,Name FROM Contacts) FROM Account WHERE Id = :accountId];
  
        return result;

    }
    
}


Can somebody help me with this?

Thank you,
Fabio

Apex Basics & Database Unit 5/5

Hello, Community, I am facing problem in solving this challenge, please advise.

Here is the criteria presented: 

With SOSL you can search against different object types that may have similar data, such as contacts and leads. To pass this challenge, create an Apex class that returns both contacts and leads that have first or last name matching the incoming parameter.

The Apex class must be called 'ContactAndLeadSearch' and be in the public scope.
The Apex class must have a public static method called 'searchContactsAndLeads'.
Because SOSL indexes data for searching, you must create a Contact record and Lead record before checking this challenge. Both records must have the last name 'Smith'. The challenge uses these records for the SOSL search.
The return type for 'searchContactsAndLeads' must be 'List<List< SObject>>'
The 'searchContactsAndLeads' method must accept an incoming string as a parameter, find any contact or lead that matches the string as part of either the first or last name and then return those records.

Error received: 

Challenge not yet complete... here's what's wrong: 
Executing the 'searchContactsAndLeads' method failed. Either the method does not exist, is not static, or does not return the expected search results.

Here is my code:

public class ContactAndLeadSearch{
    public static List<List< SObject>> searchContactsAndLead(String name)
    {
        List<List<sObject>> result=[FIND :name IN ALL FIELDS RETURNING Lead(LastName),Contact(LastName)];
                return result;
    }
}


PLEASE ADVISE...Thanks Community!!!
my custom currency field shows the right format in the detailed page like this: $1,000.00
but when i called the field in visualforce page it displayed like this: 1000.00
it's fine for me not to display the '$' sign but i need the comma, how?
help
  • March 07, 2014
  • Like
  • 1

We have built a Purchase Order system into Salesforce. The Purchase Order object is a parent of the Purchase Item object, and when the PO is approved, a trigger fires which updates all the PIs with the value of the PO Stage field.

 

However, that trigger prevents the Purchase Order from being approved, as it generates the following error:

There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger PurchaseOrderTrigger caused an unexpected exception, contact your administrator: PurchaseOrderTrigger: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0W200000091BnTEAU; first error: ENTITY_IS_LOCKED, the entity is locked for editing: []: Class.PurchaseItemTriggerMethods.copyStageToStatusFromOrder: line 131, column 1".

 

Here is the firing trigger:

trigger PurchaseOrderTrigger on Purchase_Orders__c (after update) 
{
    PurchaseItemTriggerMethods.copyStageToStatusFromOrder(Trigger.newMap);
}

 

And here are the relevant lines of the class:

    public static void copyStageToStatusFromOrder(Map<Id, Purchase_Orders__c> purchOrderMap)
    {
    
        Map<Id,Purchase_Item__c> purchItemMap = new Map<Id,Purchase_Item__c>([Select Status_Copy__c, Stage__c From Purchase_Item__c Where Purchase_Order__c IN :purchOrderMap.KeySet()]);
        Map<Id,Purchase_Item__c> purchItemMapEmpty = new Map<Id,Purchase_Item__c>(); 
        copyStageToStatusFromItem(purchItemMap.Values(), purchItemMapempty, True);
        Update purchItemMap.Values();
   
    }

 

From my research I have found that it might be something to do with using an after update and the Trigger.newMap value. However, I have not found the right changes that will fix the issue.

 

Can anyone help?