• JHayes SD
  • NEWBIE
  • 355 Points
  • Member since 2012
  • Technical Architect
  • Mavens Consulting

  • Chatter
    Feed
  • 13
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 76
    Replies

Please help me...

 

I have 20 E-mail fields named Email1__c, Email2__c, Email3__c,.....Email20__c.

What I want to do is loop thorugh these fields and input value.

 

Hereis my code.

Alerts__c alerts =new Alerts__c();
for(integer j=1;j==MailList.size();j++){
  String iStr = String.Valueof(j);
  String fieldname='Email'+iStr+'__c';
  alerts.get(fieldname)='test@test.com';
}

 But the following error occured.

 Expression cannot be assigned 

 

Please tell me how to solve this problem...

 

Thanks in advance for your help.

 

Anna

 

  • June 14, 2013
  • Like
  • 0

Need to update a custom boolean field on Product2 if PricebookEntry UnitPrice > 0.  Here is the simple trigger that I started to update the value of Product2 In_Pricelist__c field.  How do I get this portion of the trigger to work and then iterate over PricebookEnties to see if Product2Id is in list and UnitPrice > 0?

trigger trueInPricelist on Product2 (before update) {
   
   List<Product2> prods2update = new list<Product2>();
   
        for(Product2 prods : trigger.new){
            if(prods.In_Pricelist__c == Null){
                prods2update.add(prods);
        }
        if(prods2update.size() > 0){
        	for (Product2 p : prods2update){
        		p.In_Pricelist__c = True;
        		    
        }
        }
        update prods2update;
        }
}

 

Hi Everyone,

 

I am trying to build a VF Page that will sit in a standard Contact Page Layout.  I know that Account Contact Role relates to Account and there is a related list on Accounts.  What we are looking for is a way to show these Account Contact Roles on the Contact.

 

My best assumption is to create a VF Page that can be added to the standard page layout with a apex class related to the Account Contact Role where the ContactId from the AccountContactRole object is equal to the current Contact Id.

 

The following code is my VF page and Apex Class.  I feel there may already be a solution for this so I am totally open to new suggestions or fixes to my current code and logic.


Thank You Very Much.

 

<apex:page standardcontroller="Contact" recordSetVar="contacts" extensions="AccountContactRoles">
 <apex:pageBlock title="Account Contact Roles">
        <apex:form id="theForm1">
            <apex:pageBlockSection >
                <apex:dataList value="{!AccountContactRoles}" var="acr" type="1">
                    {!acr.Id}
                </apex:dataList>
            </apex:pageBlockSection>
            <apex:panelGrid columns="2">
                <apex:commandLink action="{!previous}">Previous</apex:commandlink>
                <apex:commandLink action="{!next}">Next</apex:commandlink>
            </apex:panelGrid>
        </apex:form> 
    </apex:pageBlock>
</apex:page>

 This is my VF Page Coding

 

public with sharing class AccountContactRoles {
	private final Contact acr;
	public Id cntId{get;set;}
	
	public AccountContactRoles(ApexPages.StandardSetController controller){
		this.acr = (Contact)controller.getRecord();
	}
	public ApexPages.Standardsetcontroller acrRecords{
		get{
			if(acrRecords == null){
				cntId = ApexPages.currentPage().getParameters().get('Id');
				acrRecords = new ApexPages.Standardsetcontroller(
				Database.getQueryLocator([Select Id, AccountId, ContactId, Role, IsPrimary From AccountContactRole 
				Where ContactId=:cntId]));
			}
			return acrRecords;
		}
		private set;
	}
	public List<AccountContactRole> getAccountContactRoles(){
		return (List<AccountContactRole>) acrRecords.getRecords();
	}
}

 This is my Apex Class.

Hi All,

 

I am trying to implement the jquery in visualforce and have written a sampke code but everything is working except the jquery part. Need help on checking this . Below is code 

 

<apex:page standardController="Account" sidebar="false" showHeader="true" recordSetVar="accounts">
<head>
<apex:includeScript value="{!URLFOR($Resource.jquery, '/js/jquery-1.9.1.js')}" />
<apex:includeScript value="{!URLFOR($Resource.jquery, '/js/jquery-ui-1.10.1.custom.min.js')}" />
<apex:stylesheet value="{!URLFOR($Resource.jquery, '/css/ui-lightness/jquery-ui-1.10.1.custom.css')}" />

 

<script type="text/javascript">
j$= jquery.noConflict();
j$(document).ready(function() {
j$("#flip").click(function() {
j$("#panel").slidedown();
});
});
</script>

<style type="text/css">
#panel,#flip
{
padding:5px;
text-align:center;
background-color:#e5eecc;
border:solid 1px #c3c3c3;
}
#panel
{
padding:50px;
display:none;
}
</style>
</head>
<body>
<apex:form >
<div id="flip">
Click to See
</div>
<div id="panel">
<p>Hello testing the jquery functionality</p>
<apex:actionFunction immediate="true" name="jq" />
</div>
</apex:form>
</body>
</apex:page>

 

i am using recent jquery library and compressed zip is stored in static resources.

  • March 14, 2013
  • Like
  • 0

I'm running into a system limit issue with a trigger that calls a class if I activate it via the dataloader.  I'm not sure if it's the trigger or the class causing the exception.  Hopefully it is the trigger since it's so much smaller and should be easier to fix.  Can someone please take a quick look and let me know what is causing this to hit limits and how I can fix it?  It works fine on an individual record edit basis and I even tested it with a small upload and it worked fine but when I went to do the actual upload it froze up with all these errors.

 

Thanks,

Amanda

 

Trigger

trigger CloneOpportunityRollover on Opportunity (after Insert, after Update) {
for(Opportunity opp : Trigger.New){

ApexPages.StandardController controller = new ApexPages.standardController(opp );

OpportunityCloneWithItemsController clone = new OpportunityCloneWithItemsController(controller);

// load the current record
opp = (Opportunity)controller.getRecord();

if (opp.Hidden_New_Class_Start_Date__c != null) {
clone.clonewithitems();

}}}

Hi -

I'm trying to create a formula (in a workflow)-

 

If the Length of field "Invoice Line Number" is 1,

make the field "Invoice_Number + "-0" + "Invoice Line Number" (add a zero to Invoice line number in front)

otherwise, just make the result "Invoice_Number + "-" + "Invoice Line Number"

 

My formula:

 

IF(LEN(TEXT(Invoice_Line_Number__c)),1, ("0"+ TEXT(Invoice_Line_Number__c)), (Invoice_Line_Number__c))

 

I keep getting Syntax errors, such as

Error: Incorrect parameter type for function 'IF()'. Expected Boolean, received Number

 

I have tried all sorts of changes, like putting the "1" in quotes, I have counted the parenthesis, and nothing is getting this right.

 

Thank you!!

Sara

  • October 19, 2012
  • Like
  • 0

<apex:page >
 <apex:includeScript value="{!URLFOR($Resource.Jquery, 'js/jquery-1.9.0.custom.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.Jquery, 'js/jquery-ui-1.9.0.custom.min.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.Jquery, 'css/ui-lightness/jquery-ui-1.9.0.custom.css')}"/> 
 
<script type="text/javascript">
var j$ = jQuery.noConflict();

j$(document).ready(function(){
j$("#jqexample").click(function() {
alert("Jquery example!!!!!");
});
});
</script>

 <a id="jqexample" href="">jqexample!</a> 

</apex:page>

 

 

 

jquery is not working with with the above code . were is the problem ?  Guys help needed

  • October 17, 2012
  • Like
  • 0

How can I populate my select list with the product names?  I know instead of creating new options:

 List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('US','US'));
options.add(new SelectOption('CANADA','Canada'));
options.add(new SelectOption('MEXICO','Mexico'));
return options;

 

I have to call the name field in the products object but i can't fiqure out how to do it.  Anyone got any ideas?

-Hkp716

 

 

public with sharing class plist1 {
String[] prods = new String[]{};

public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('US','US'));
options.add(new SelectOption('CANADA','Canada'));
options.add(new SelectOption('MEXICO','Mexico'));
return options;
}

public String[] getprods() {
return prods;
}

public void setprods(String[] prods) {
this.prods = prods;
}


public List<Product2> getProducts() {

List<Product2> ProductsForPage = [Select Id,Name,Brand__c From Product2];
return ProductsForPage;


}
}

  • October 17, 2012
  • Like
  • 0

Hi,

I have  custom object in Salesforce name  'Project' and It has a Picklist Field 'Proj Implementation' Type.

and my second custom object is name 'SEC' and it has picklist(Multiselect) field name 'SEC DD'.

I want to compare if  value of 'Proj Implementatuon Type' equals to 'SEC DD' then add some records.

How can i do this comparison.

Can anyone plz guide?

 

Thanks in advance.

Rajashri

I am trying to figure out how to modify a extension class I found on a Salesforce blog.

 

I am trying to modify it to add a attachment to a new record.  The comments made in order to accomplish this function is to

"If you want to attach the uploads to a new, not yet extant, object, make the "myAttachment" variable belong to the controller, not just scoped within the upload function. Then the attachment remains as part of the controller until the controller finally runs save(). 

 

Within your controller's save() function you do this:

insert myNewRecord;
myAttachment.parentId = myNewRecord.Id
insert myAttachment; "

 

 

 

I cannot figure out how to accomplish this, can anyone help organize the code to create a new record with an attachment? The rest of the code is below.

 

 

Controller:

 

public class VFFileUpload  
{  
    public Id recId  
    {    get;set;    }  
      
    public VFFileUpload(ApexPages.StandardController ctlr)  
    {  
       recId = ctlr.getRecord().Id;       
    }  
      
    public string fileName   
    {    get;set;    }  
      
    public Blob fileBody   
    {    get;set;    }  
    
    public PageReference UploadFile()  
    {  
        PageReference pr;  
        if(fileBody != null && fileName != null)  
        {  
          Attachment myAttachment  = new Attachment();  
          myAttachment.Body = fileBody;  
          myAttachment.Name = fileName;  
          myAttachment.ParentId = recId;  
          insert myAttachment;  
           pr = new PageReference('/' + myAttachment.Id);  
           pr.setRedirect(true);  
           return pr;  
        }  
        return null;  
    }      
}

 

____________________________________

 

Visualforce Code:

 

<apex:page standardController="Account" extensions="VFFileUpload">  
  <apex:form >
  <apex:pageBlock title="A Block Title">
 
   <apex:outputLabel >Account Name </apex:outputLabel>
  <apex:inputField value="{!account.Name}"/>
  <apex:outputLabel >Account Phone </apex:outputLabel><br/>
  <apex:inputField value="{!account.Phone}"/><br/>
  </apex:pageBlock>
      <apex:pageBlock title="Upload Attachment">  
            <apex:inputFile style="width:100%" id="fileToUpload" value="{!fileBody}" filename="{!fileName}" />  
            <apex:commandButton value="Upload Attachment" action="{!UploadFile}"/>  
       </apex:pageBlock>  
  </apex:form>  
</apex:page>

 

 

  • September 26, 2012
  • Like
  • 0

Is it possible to refresh master page from a visual force page that is embeded on the opportunity layout ??

 

Thanks for all the help.

 

I already tried calling JS functions like window. and doing the following in the controller:

 

 PageReference curPage = new ApexPages.StandardController(opp).view();
       curPage.setRedirect(true);
       return curPage ;

 

I currently have an SOQL statement in my Apex extenstion for a visualforce page with the following

CGM = [Select id FROM OpportunityLineItem WHERE Opportunity.Owner.ID = :cntact.id AND Opportunity.CloseDate >= :beginDate ];

 

When I run the Visual Force page I receive the following error:

Argument 1 cannot be null 

 

An unexpected error has occurred. Your development organization has been notified.

 

However when I change the SOQL statement to the following(without the > in the bold text) there is no error on the visual force page. It even pulls the Opportunity products from Opporunities that closed on beginDate.

CGM = [Select id FROM OpportunityLineItem WHERE Opportunity.Owner.ID = :cntact.id AND Opportunity.CloseDate = :beginDate ];

 

This is the code for beginDate. byear and bmonth are integers set by the visualforce page.

public Date beginDate;

public Date getBeginDate(){
if(bmonth!=null && byear!=null){
beginDate = date.newInstance(Integer.valueOf(byear),Integer.valueOf(bmonth),1);
return beginDate;
}else{
return null;
}
}

 

Like I said everything is working as expected without the > but breaks when it is added.

 

Thanks in advanced for your help.

 

-JimmyJ

 

The following works:

<apex:column headerValue="Opportunity Id">{!CASESAFEID(op.Id)}</apex:column>

 

But if I replace the above with the one-liner below, where I specify the value in the value= field of the apex:column, it fails to save with the error:

Syntax error: Missing ')'


<apex:column headerValue="Opportunity Id" value="{!CASESAFEID(op.Id)}" />

 

That seems wierd, there is no missing or mismatched paren there.  I cannot seem to modify the line to get it to save.  I can also reproduce the error with other formula expressions, it is not specific to CASESAFEID.   Is this a bug?


Requirement :- I have two objects Nomination__c and Participant__c. Hight level these object are related to Training.

Participants get nominated for Trainings. Nomination has capture all details of Participants so that if participants does not exist then it create new participants. abc_Email_ID__c is the field which we use to check if participant exist or not. "abc_Email_ID__c" is external id in Nomination and Participant__c.

 

I want ot use cascade inset functionality in Berfore Insert trigger on Nomination.Idea is insert Participant__c and associate atutomatically with Nomination when Nomination record is inserted.

Below is the sample code i am trying to run through Anonymous block when i am running it gives me following error

 

|System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD, Foreign key external ID: testing119@abc.com not found for field abc_Email_ID__c in entity Participant__c: []

 

Any idea why i am getting this error

 

code :-

 

Nomination__c nomiObj = new Nomination__c();
nomiObj.Employee_Name__c='testing119';
nomiObj.abc_Email_ID__c='testing119@abc.com';
nomiObj.Training_Name__c='a01Z000000O8EeS';
Participant__c partObj = new Participant__c();
            
            partObj.abc_Email_ID__c=nomiObj.abc_Email_ID__c;
             
             nomiObj.EmployeeID__r=partObj;
insert nomiObj;

I have the requirement  create a trigger on Attachment object, when i add new attachment ,check the attchment alredy aded or not?

 

i write like this ,please suggest me, is it correct or not?

 

 

trigger dntAddDuplicateAttchmnt on Attachment (before insert) {
if(trigger.isBefore){
for(Attachment atch:Trigger.new){
String parentID=atch.ParentId;
String atchName=atch.Name;
List<Attachment> listatch=[SELECT Name,ParentId FROM Attachment];
if(parentID==trigger.oldmap.get(parentID).ParentId && atchName==trigger.oldmap.get(parentID).Name){
atch.addError(' This file already having with same name in your attachmntes');
}
else if{
for(Attachment at:listatch){
if(at.Name==atchName && at.ParentId==parentID){
atch.addError('This file already having with same name in your attachmntes');
}
}
}

}
}

}

Please help me...

 

I have 20 E-mail fields named Email1__c, Email2__c, Email3__c,.....Email20__c.

What I want to do is loop thorugh these fields and input value.

 

Hereis my code.

Alerts__c alerts =new Alerts__c();
for(integer j=1;j==MailList.size();j++){
  String iStr = String.Valueof(j);
  String fieldname='Email'+iStr+'__c';
  alerts.get(fieldname)='test@test.com';
}

 But the following error occured.

 Expression cannot be assigned 

 

Please tell me how to solve this problem...

 

Thanks in advance for your help.

 

Anna

 

  • June 14, 2013
  • Like
  • 0

Need to update a custom boolean field on Product2 if PricebookEntry UnitPrice > 0.  Here is the simple trigger that I started to update the value of Product2 In_Pricelist__c field.  How do I get this portion of the trigger to work and then iterate over PricebookEnties to see if Product2Id is in list and UnitPrice > 0?

trigger trueInPricelist on Product2 (before update) {
   
   List<Product2> prods2update = new list<Product2>();
   
        for(Product2 prods : trigger.new){
            if(prods.In_Pricelist__c == Null){
                prods2update.add(prods);
        }
        if(prods2update.size() > 0){
        	for (Product2 p : prods2update){
        		p.In_Pricelist__c = True;
        		    
        }
        }
        update prods2update;
        }
}

 

I need some help creating a test code or some how making my Class pass Code Coverage - it currently has 0% and I can't deploy to Production.

 

How do I get this Class to pass.

 

public class NewDealerApproval {

    // Author: Cheryl Lefeber

   

    static final Map<String,Approval_Matrix_New_Dealer__c> APPROVAL_MAP_CONST;

   

    static {

        APPROVAL_MAP_CONST = getNewDealerApprovalMap();

    }

   

    private static Map<String,Approval_Matrix_New_Dealer__c> getNewDealerApprovalMap(){

        // build a Map from Reps (concatenated Field Rep and Service Rep) --> Approval Matrix New Dealer record

        Map<String,Approval_Matrix_New_Dealer__c> results = new Map<String,Approval_Matrix_New_Dealer__c>();

        List<Approval_Matrix_New_Dealer__c> records = [select id,name,Reps__c,

        Final_Approver_BDM__c,Final_Approver_TAM__c,Final_Approver_RBD__c,Account_rep__c,

        Final_Approver_FSD__c,Pre_Approver_TAM__c,Pre_Approver_BDM__c  from Approval_Matrix_New_Dealer__c];

        for(Approval_Matrix_New_Dealer__c record : records){

         if (!results.containsKey(record.Reps__c))

 

results.put(record.Reps__c, record);

        }

        return results;

        }

  

       public static void setNewDealerApprovers(Application__c[] applications){

        for (Application__c p:applications){

            if (p.reps__c != null) {

                if ( APPROVAL_MAP_CONST.containsKey(p.Reps__c))

{

                    p.final_approver_BDM__c = APPROVAL_MAP_CONST.get(p.Reps__c).final_approver_BDM__c;

                    p.final_approver_TAM__c = APPROVAL_MAP_CONST.get(p.Reps__c).final_approver_TAM__c;

                    p.final_approver_RBD__c = APPROVAL_MAP_CONST.get(p.Reps__c).final_approver_RBD__c;

                    p.final_approver_FSD__c = APPROVAL_MAP_CONST.get(p.Reps__c).final_approver_FSD__c;

                    p.pre_approver_BDM__c = APPROVAL_MAP_CONST.get(p.Reps__c).pre_approver_BDM__c;

                    p.pre_approver_TAM__c = APPROVAL_MAP_CONST.get(p.Reps__c).pre_approver_TAM__c;

                    p.account_rep__c = APPROVAL_MAP_CONST.get(p.Reps__c).account_rep__c;

               } else {

                    p.final_approver_BDM__c=null;

                    p.final_approver_TAM__c=null;

                    p.final_approver_RBD__c=null;

                    p.final_approver_FSD__c=null;

                    p.pre_approver_BDM__c=null;

                    p.pre_approver_TAM__c=null;

                    p.account_rep__c=null;

 

                }

            }

        }

    }

}

I have a junction object with to MD-relationships, one for contact and one for a custom object named program. The trigger works fine in the sandbox and i have to test it to use it in production. I tried writing the test code but it doesn't  work. Can someone please help me, what code do I need to write for the testing of this trigger and where do I have to place it?

 

trigger insert_case on Affiliated_Programs__c (before insert, before update) {
   for (Affiliated_Programs__c ci : trigger.new) {

   //Checks the database for all affiliated programs with the same program and contact
      List<Affiliated_Programs__c> resultList = [SELECT id, Name FROM Affiliated_Programs__c
      WHERE Contact__c = :ci.Contact__c
      AND Program__c = :ci.Program__c];

   // Raise the error back if any records found
       if (!resultList.isEmpty()) {
          System.debug('Found another copy ' + resultList[0].id + ' name is ' + resultList[0].Name);
          ci.addError('Duplicate record, a Contact is already related to that program');
       }
   }
}

hi folks this is my first attempt at writing a trigger - not going well! here's what i'm trying to do....

 

i have a custom object called Booking__c that has a lookup field called Commission_Agent__c. 

 

Booking__c is related via lookup to another custom object called Property__c.

 

Property__c has a lookup to a Contact record called Contact_Commission_Agent__c.

 

When a new Booking is created (not every time it's edited, just on creation - or directly after it's created i'm assuming), i need the trigger to lookup the Property__c record via the lookup Field Property__c on Booking__c - then update the Commission_Agent__c field with the id of the Contact_Commission_Agent__c field on the property object. 

 

here's what i have so far. 

 

trigger AssignCommAgent on Booking__c (after insert, before update)
{
//instantiate set to hold unique deployment record ids
Set<Id> bookingIds = new Set<Id>();
for(Booking__c s : Trigger.new)
{
bookingIds.add(s.Property__c);
}

//instantiate map to hold deployment record ids to their corresponding ownerids
Map<Id, Property__c> propertyCommAgentMap = new Map<Id, Property__c>([SELECT Id, Contact_Commission_Agent__c FROM Property__c WHERE Id IN: bookingIds]);

for (Booking__c s : Trigger.new)
{
if (s.Commission_Agent__c == null && propertyCommAgentMap.containsKey(s.Property__c))
{
s.Commission_Agent__c = propertyCommAgentMap.get(s.Property__c).Contact_Commission_Agent__c;
}
}
}

 

here's my error. 

 

Error:Apex trigger AssignCommAgent caused an unexpected exception, contact your administrator: AssignCommAgent: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.AssignCommAgent: line 17, column 1

 

any insights are greatly appreciated!

Hi Everyone,

 

I am trying to build a VF Page that will sit in a standard Contact Page Layout.  I know that Account Contact Role relates to Account and there is a related list on Accounts.  What we are looking for is a way to show these Account Contact Roles on the Contact.

 

My best assumption is to create a VF Page that can be added to the standard page layout with a apex class related to the Account Contact Role where the ContactId from the AccountContactRole object is equal to the current Contact Id.

 

The following code is my VF page and Apex Class.  I feel there may already be a solution for this so I am totally open to new suggestions or fixes to my current code and logic.


Thank You Very Much.

 

<apex:page standardcontroller="Contact" recordSetVar="contacts" extensions="AccountContactRoles">
 <apex:pageBlock title="Account Contact Roles">
        <apex:form id="theForm1">
            <apex:pageBlockSection >
                <apex:dataList value="{!AccountContactRoles}" var="acr" type="1">
                    {!acr.Id}
                </apex:dataList>
            </apex:pageBlockSection>
            <apex:panelGrid columns="2">
                <apex:commandLink action="{!previous}">Previous</apex:commandlink>
                <apex:commandLink action="{!next}">Next</apex:commandlink>
            </apex:panelGrid>
        </apex:form> 
    </apex:pageBlock>
</apex:page>

 This is my VF Page Coding

 

public with sharing class AccountContactRoles {
	private final Contact acr;
	public Id cntId{get;set;}
	
	public AccountContactRoles(ApexPages.StandardSetController controller){
		this.acr = (Contact)controller.getRecord();
	}
	public ApexPages.Standardsetcontroller acrRecords{
		get{
			if(acrRecords == null){
				cntId = ApexPages.currentPage().getParameters().get('Id');
				acrRecords = new ApexPages.Standardsetcontroller(
				Database.getQueryLocator([Select Id, AccountId, ContactId, Role, IsPrimary From AccountContactRole 
				Where ContactId=:cntId]));
			}
			return acrRecords;
		}
		private set;
	}
	public List<AccountContactRole> getAccountContactRoles(){
		return (List<AccountContactRole>) acrRecords.getRecords();
	}
}

 This is my Apex Class.

Hi, I'm testing a controller extension, run as a standard System Admin user, but my test class fails with the error "Read access denied for IBOS_Request__c", which I don't understand since Sysem Admin has full access to the IBOS_Request__c custom object. Thoughts?

 

TEST CLASS:

@isTest
class TestIBOSRequest
{
    static testMethod void TestIBOSRequest()
    {
        User u_adm = TestUtils.getAdminUser('adm');
        insert u_adm;
        
        ApexPages.StandardController std = new ApexPages.StandardController(ir1);
        IBOSRequestContExt irce = new IBOSRequestContExt(std);
        
        system.runAs(u_adm)
        {
            std = new ApexPages.StandardController(new IBOS_Request__c());
            irce = new IBOSRequestContExt(std);
        }
    }
}

 TestUtils Class:

Public class TestUtils
{
 private static User getTestUser(String userName, String profileName)
    {
        String profileId;
        try
        {
            profileId = [SELECT Id FROM Profile WHERE Name like: '%'+profileName+'%' limit 1].Id;
        }
        catch(Exception ex)
        {
            System.debug(ex);
            System.assert(false, 'No profile exists with name '+ profileName);
        }
        User testUser = new User();
        testUser.LastName = 'test ' + UserName;
        testUser.Alias = UserName;  
        testUser.Email = UserName+'@accruent.com';
        testUser.Username = UserName+UserName+'@test.com';
        testUser.CommunityNickname = 'a'+UserName;
        testUser.TimeZoneSidKey = 'America/New_York';
        testUser.LocaleSidKey = 'en_US';
        testUser.EmailEncodingKey = 'ISO-8859-1';
        testUser.ProfileId = profileId;
        testUser.LanguageLocaleKey = 'en_US';
        testUser.IsActive = true;
        
        return testUser;    
    }
    
    public static User getAdminUser(String adminName)
    {
        return getTestUser(adminName, 'System Administrator');
    }
}

 

Hi,

     I wrote Dynamic  soql  for getting records,but am not able to get the solution..Could any one resolve it..........

Error is::

System.QueryException: line 1:59 no viable alternative at character '%'

Error is in expression '{!gettin_objs}' in component <apex:page> in page recsearch
 
Apex Code:
public class recsearchcls {
       public string searchword{get;set;}
   List<SelectOption> finalobj= new List<SelectOption>();

public PageReference gettin_objs() {
  string fword= '%'+searchword+'%';
      List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
             for(Schema.SObjectType f : gd){  
             if(searchword!=null || searchword!=''){     
                list<sobject> ss=Database.query('Select id,Name from '+f+'where Name Like: '+fword);
              
                //if(ss.NOT(isempty())){
                 finalobj.add(new SelectOption(f.getDescribe().getName(),f.getDescribe().getName()));    
         // }
         }
       }
    return null;
}

}

-------

v.f:

<apex:page controller="recsearchcls">
    <apex:form >
    <apex:PageBlock >
      <br/><h1><b>Search In Multiple Objects</b></h1><br/><br/><br/>
      <b>Enter Here:</b>   <apex:inputtext value="{!searchword}" onkeydown="sss()">
      <apex:actionfunction action="{!gettin_objs}" name="sss"/>
      </apex:inputtext>
      <apex:commandButton action="{!search}" value="Search"/>
      <apex:pageBlockSection >
      <apex:selectCheckboxes value="{!check}" style="float:left" layout="pageDirection"  >
       <apex:selectOptions value="{!ren}"/>     
       </apex:selectCheckboxes>
     </apex:pageBlockSection>
     </apex:PageBlock>
      </apex:form>  
</apex:page>

 

I want to pull a list of Leads from a SOQL query, where the Leads meet some requirements, and are also found in another list from a previous query.

 

A dumbed down version of what I've got:

 

List<AggregateResult> numTasks = [SELECT WhoId
    FROM Task
    WHERE
        status='Completed' AND
        isClosed = true AND
        ActivityDate = LAST_N_DAYS:35
    GROUP BY WhoId
    HAVING count(id) >= :TASKS_MAX];

List<Lead> openLeads = [Select id, ownerId
    FROM Lead
    WHERE
        OwnerId = 'Enter a queue ID here' AND
        Days_Since_Modified__c <= :NUM_OF_DAYS_TO_WATCH AND
        Id IN :numTasks];

 I get:"Error: Compile Error: Invalid bind expression type of SOBJECT:AggregateResult for Id field of SObject Lead at line 63 column 25"

 

I understand it's a type issue, but I find it funny I can go from a Lead List to an Aggregate Result, but not vice versa.

 

How do I do this correctly?  I can't seem to find anything about AggregateResult Lists in the developer's guide that addresses this.

 

Hi All,

 

I am trying to implement the jquery in visualforce and have written a sampke code but everything is working except the jquery part. Need help on checking this . Below is code 

 

<apex:page standardController="Account" sidebar="false" showHeader="true" recordSetVar="accounts">
<head>
<apex:includeScript value="{!URLFOR($Resource.jquery, '/js/jquery-1.9.1.js')}" />
<apex:includeScript value="{!URLFOR($Resource.jquery, '/js/jquery-ui-1.10.1.custom.min.js')}" />
<apex:stylesheet value="{!URLFOR($Resource.jquery, '/css/ui-lightness/jquery-ui-1.10.1.custom.css')}" />

 

<script type="text/javascript">
j$= jquery.noConflict();
j$(document).ready(function() {
j$("#flip").click(function() {
j$("#panel").slidedown();
});
});
</script>

<style type="text/css">
#panel,#flip
{
padding:5px;
text-align:center;
background-color:#e5eecc;
border:solid 1px #c3c3c3;
}
#panel
{
padding:50px;
display:none;
}
</style>
</head>
<body>
<apex:form >
<div id="flip">
Click to See
</div>
<div id="panel">
<p>Hello testing the jquery functionality</p>
<apex:actionFunction immediate="true" name="jq" />
</div>
</apex:form>
</body>
</apex:page>

 

i am using recent jquery library and compressed zip is stored in static resources.

  • March 14, 2013
  • Like
  • 0

I've looked at the other posts regarding this but can't figure out what I'm doing wrong. I'm trying to get a lead field updated when a campaign member is added with a status of responsed (starts with a responded status, for campaigns other than webinars and tradeshows).

 

I get this error via email when I try to mass add a member list of responses: SaveAdminActivate: System.Exception: Too many SOQL queries: 101

 

trigger SaveAdminActivate on CampaignMember (after insert) {
    // Query for all the contact information
    List<Id> leadsIds = new List<Id>{};
    for(CampaignMember member : trigger.new) {
        if (member.Status=='Responded' && member.Campaign_Type__c  != 'Webinar' && member.Campaign_Type__c  != 'Tradeshow / Conference' && member.LeadId != null) {
            leadsIds.add(member.LeadId);
        }
    }
    List<Lead> leadsOld = [SELECT Id FROM Lead WHERE Id in :LeadsIds];

    // Change all the lead records
    List<Lead> leadsNew = new List<Lead>{};
    for (Lead l : leadsOld) {
        l.Non_PURL_Lead__c=true;
        l.Apex_Context__c=true;
        // perform some update to lead record
        leadsNew.add(l);
    }

    // Update all the queries at once
    if(!leadsNew.isEmpty()){
    	update leadsNew;
    }
}

 

Thanks in advance for any replies!

  • March 11, 2013
  • Like
  • 0

I'm running into a system limit issue with a trigger that calls a class if I activate it via the dataloader.  I'm not sure if it's the trigger or the class causing the exception.  Hopefully it is the trigger since it's so much smaller and should be easier to fix.  Can someone please take a quick look and let me know what is causing this to hit limits and how I can fix it?  It works fine on an individual record edit basis and I even tested it with a small upload and it worked fine but when I went to do the actual upload it froze up with all these errors.

 

Thanks,

Amanda

 

Trigger

trigger CloneOpportunityRollover on Opportunity (after Insert, after Update) {
for(Opportunity opp : Trigger.New){

ApexPages.StandardController controller = new ApexPages.standardController(opp );

OpportunityCloneWithItemsController clone = new OpportunityCloneWithItemsController(controller);

// load the current record
opp = (Opportunity)controller.getRecord();

if (opp.Hidden_New_Class_Start_Date__c != null) {
clone.clonewithitems();

}}}