• ScriptMonkey
  • NEWBIE
  • 130 Points
  • Member since 2010
  • Software Engineer

  • Chatter
    Feed
  • 2
    Best Answers
  • 2
    Likes Received
  • 1
    Likes Given
  • 28
    Questions
  • 42
    Replies
How to avoid Too Many Future callouts!!!!!!Help me
I want to send contact info of particler lead to my 3rd party...
dis code will fine for 9-records



my trigger is

trigger conupdater on Contact(after insert,after update,before delete)
{
    list <lead> l=[Select id,name,lastname,firstname from lead];
    BuzzBoard_Setting__c bb=[select id,Name,Partner_key__c from BuzzBoard_Setting__c Order by CreatedDate DESC LIMIT 1];
    public String mymethod;
    public String type='Contact'; 
    Map<id,id> contMap=new Map<id,id>();
  
    if(Trigger.isAfter)
    {
      for(contact cont:Trigger.new){     
         if(cont.ContactLead__c!=null){
             contMap.put(cont.id,cont.ContactLead__c);
         }
    }
 
    }  
    if((Trigger.isAfter && Trigger.isInsert))
    {
    for(contact c:Trigger.New){
        mymethod='INSERT';
        if(contMap.containsKey(c.id)){
            LeadChildsUpdater_bb.updatenotes(c.id,contMap.get(c.id),mymethod,type,bb.Partner_key__c);
        }
      
    }
    }

    if((Trigger.isAfter && Trigger.isUpdate))
    {
    for(contact c:Trigger.New){
        mymethod='UPDATE';
        if(contMap.containsKey(c.id)){
            LeadChildsUpdater_bb.updatenotes(c.id,contMap.get(c.id),mymethod,type,bb.Partner_key__c);
        }
    }
    }

    if((Trigger.isBefore && Trigger.isDelete))
    {
    for(contact cont:Trigger.old){     
         if(cont.ContactLead__c!=null){
             contMap.put(cont.id,cont.ContactLead__c);
         }
    }
    for(contact c:Trigger.Old){
        mymethod='DELETE';
        if(contMap.containsKey(c.id)){
            LeadChildsUpdater_bb.updatenotes(c.id,contMap.get(c.id),mymethod,type,bb.Partner_key__c);
        }
    }
    }
}

My Controller class is ::
 
public class LeadChildsUpdater_bb
{
public static string resmessage;
@Future(callout=true)

  public static void updatenotes(String Id,String Lead_Id,String Action,String Type,String Key)
  {
  
    HttpRequest req = new HttpRequest();
    req.setEndpoint('https://demo.mybuzzboard.com/salesforce/assetsSync.php');
    req.setMethod('POST');
    req.setBody('Id='+EncodingUtil.urlEncode(+Id, 'UTF-8')+'&Lead_Id='+EncodingUtil.urlEncode(+Lead_Id, 'UTF-8')+'&Action='+EncodingUtil.urlEncode(+Action, 'UTF-8')+'&Type='+EncodingUtil.urlEncode(+Type, 'UTF-8')+'&Key='+EncodingUtil.urlEncode(+Key, 'UTF-8'));
    Http http = new Http();
    HttpResponse res = http.send(req);
 
    if (res.getStatusCode() == 200)
    {
          
          
             System.debug('---------------------'+res.getBody());
     }
    else
     {
      System.debug('Callout failed: ' + res);
     }

}
}
I found this out the very hard way and I would like to share my findings to either warn others, or find out if I've done something wrong somehow.  Sobjects cannot be handed lists of objects via addAll (even though they can be added objects one at a time through add, and OTHER methods that have sObject lists as parameters can accept object lists).

I'll show by example:
Account a = new Account();
sObject s
LIST<sObject> sOjbList = new LIST<sObject>();
sOjbList.add(s);
sOjbList.add(a);
That works perfectly fine, as you'd expect.
sObject s1;
sObject s2;
LIST<sObject> sList = new LIST<sObject>{s1, s2};
LIST<sObject> sOjbList = new LIST<sObject>();
sOjbList.addAll(sList);
Also works fine.

This, however, will fail.
LIST<Account> aList = new LIST<Account>{new Account(), new Account()};
LIST<sObject> sOjbList = new LIST<sObject>();
sOjbList.addAll(aList);
It gives the errors:
Incompatible argument type LIST for All method on LIST
OR
Incompatible argument type LIST<Account> for All method on LIST<SObject>
(Based on if you're using the Developer Console or something else, like MavensMate)

But don't fret, there's a solution (albeit a silly one)
private LIST<sObject> objToSobj(sObject[] objList)
{
	return objList;
}
That's right, pass your objList through this (and it will let you without problem) and all works fine.

Thoughts?
I'm facing an issue in a package I've released that has an intermittant problem.  There are orgs with 600k contacts and this code works fine, but there is an org with 200k records and it fails with the non-selective query error.

here's the pseudocode:

[SELECT
(SELECT id from objectA),
(SELECT id from objectB)
FROM contact WHERE id IN
(SELECT Contact__c FROM objectC WHERE id IN :listOfObjIDs)]

listOfObjIDs is a list of strings that has IDs in objectC built from an after insert trigger on objectC
objectC is a child object of Contact with a field Contact__c containing its contact
Objects A and B are also children of Contact

ID in indexed, and listOfObjIDs cannot contain any null values unless you can have required fields as null in a trigger.new reference (the parent's value can't be null on a child record).

I'm looking for any advice or suggestions anyone might have, I'm usually pretty solid in SOQL but I can't understand how this is an issue in some orgs and not others.

Additional note: in the org having the problem, the only object in the entire org over 100k records is contact, the rest have less than a few thousand, so it needs to be the contact-based part of the query.

So we enabled communities and ChatterAnswers on our org and it has caused no end of problems.  When trying to deploy from sandbox to production and the test classes keep failing in ChatterAnswers (even though we're not deploying anything there).  I know it's because all tests have to run on deploy, but it seems the tests are problematic.

 

First there was one that gets the first user and assigns an account to it.  Since you can't assign an accuont to an inactive user, and our first user happens to be inactive, the test fails.  So I had to edit it to select the first ACTIVE user, and that test passes now.  Now I'm getting another failure with the class ChatterAnswersEscalationTriggerTest failing with errors.

 

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []", Failure Stack Trace: "Class.ChatterAnswersEscalationTriggerTest.validateQuestionEscalation: line 14, column 1"

 

Advice is welcome as to how to fix this.  This has, literaly, crippled our development because we can't push any product into where it's getting used on our internal ORG.

 

I have a visualforce page that shows a child object of Contact.  I tried refrencing the contact.object__r in a visualforce page, putting it in a apex:repeat command.  This works fine when vieing /apex/VFpage, but on sites it doesn't see the values in the sub-object.

Then I tried a second SOQL statement instead, putting it in a varaible "Objects" then repeating on that.  Again, it works fine in  apex mode, but on the site, it stops working.

 

Now the really confusing part. I made a sub-class and iterated through the objects variable, setting an array of this sub-class, setting values from the objects variable, then used THAT in the Visualforce page and looped through it, and it worked fine, sites and apex both.

 

Any idea what can cause this kind of issue? It's clearly not permissions it's just weird handling in visualforce.

Thanks in advance.  I'm trying to lock down a script I wrote with a bug in it.  You can trick my script into outputting a list of users instead of the list it's mean to do.

 

That problem is fixed, it was a code error I shouldn't have made in the first place, but the question I have now is this.

 

Is there a way to block the user object from being viewed by a site guest user?  It's not listed in permissions, but I can very definately see a list of all users when I exploit my code.  I want to disable this access so even if I miss something another time, this particular error can't happen again because of SF protections.

 

How do I manage the Guest User's ability to view the User table?

I've written a Visualforce page to edit "Custom" style salesforce email templates, but it lets you use a WYSIWYG editor rather than needing to know html or coping and pasting from another software. That all works great, and everything is good to go except one functionality.  I'm recreating the "send test email" from the salesforce interface.

 

I've got it asking for whatId and setTargetObjectId (so I can use the template and have it merge everything) as well as adding a new email address to the mail.setToAddress() method, and all seems good.  

 

The only problem is that the email goes to the setTargetObjectId as well as the email addresses I added.  I want to use the setTargetObjectId to merge all the fields into the email, but suppress the email to that contact.  I know there is a checkbox on the salesforce test email window referring to "send Preview Email" and I need to reproduce that functionality.

 

Here's my code to send the email, if it helps..

'

            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setTargetObjectId(dummytask.whoid);
            transient string[] toAddresses = new list<string>();
            toAddresses.add(testEmailTo);
            mail.setToAddresses(toAddresses);
            mail.setWhatId(dummytask.whatid);
            mail.setTemplateId(idToTest);
            mail.setReplyTo('noreply@mycompany.com');
            mail.setSenderDisplayName('Email Test');
            mail.setSaveAsActivity(false);
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
            dummyTask = new task();
            idTotest = null;

 

I've been developing on salesforce for several years now and have come across the problem of writing code, testing then packaging it, and having it give an odd error when installed on a different org.  This is always frustrating because in the dev org the error says the line number, etc, but on the other org with the package installed, it just says error, and the debug logs cannot get into the managed code to show details.  I always undestood this as par for the course, and use the notification emails and such, and resolve issues that way.

 

Now I'm getting the same ambiguous error on my development org!  my log files say "entering Managed Pkg" rather than showing me what's going on, debugs are not shown, and the like.  There are no packages of any kind installed on my dev org, the only package that exists is the one I'm making there (and it's not installed there, that wouldn't make sense).

 

How can I debug or develop when salesforce hides my own code from me.  The package is managed, but that shouldn't matter where you're writing the code.  This used to be fine, was this a recent bug, or is it a new method that salesforce is implementing?

 

 

I've been using the Force.com IDE for my development, but I'm reading, and experiencing, that many people have huge issues trying to use version control with that as well.

 

For one person, SVN works fine, or Git, but I work on a team.  Importing SVN causes a nightmare of dependancies and XML issues to work through, and Git doesn't even save to salesforce when you use eclipse's GIT functions, so nothing you imported actually went to the server.

 

I really like using Eclipse, but Git is more important for our team, and I'm reaching out to ask if anyone has another way to develop on force.com that can use Git, or has gotten Eclipse and Git to play nice with salesforce?

 

Thanks.

I've got a problem that I can't seem to resolve.  Here's my VisualForce code and Apex code.  When I uncomment out the expressions line in the Apex code, clicking the "save" button just loads the whole controller, with that line commented out, clicking save just executes the save function and triggers that two debug statements as I expect it to.

 

Any advice is very welcome, I've been staring at this all day.

 

VF:

<apex:page controller="testSaveController" showHeader="false" cache="false" 
	sidebar="false" standardStylesheets="false">
	<apex:form id="theForm">
		<apex:dynamicComponent componentValue="{!fieldDisplay}" />
		<center>
		<apex:commandButton action="{!save}" value="Save" id="theButton" rerender="theForm"/>
		</center>
	</apex:form>
</apex:page>

 

APEX:

public with sharing class testSaveController
{
	public LIST<string> fieldValues					{ get; set; }
	
	public testSaveController()
	{
		//constructor
	}
	
	public Component.Apex.OutputPanel getFieldDisplay()
	{
		fieldValues = new LIST<string>();
		fieldValues.add('testVal');
		
		Component.Apex.OutputPanel formContainer = new Component.Apex.OutputPanel();
		
		Component.Apex.InputText dynInpText = new Component.Apex.InputText();
//		dynInpText.expressions.value = '{!fieldValues[0]}';
		dynInpText.id = 'field0';
		formContainer.childComponents.add(dynInpText);

		return formContainer;
	}
	
	public void save()
	{
		system.debug('----------------------------------------------');
		system.debug(fieldValues);
	}
}

 

 

I have a commandButton that runs an action (confirm) and an oncomplete (window.location={!redirectURL}).  The problem is that the confirm method changes the redirectURL variable, but it's seeing the old one, probably because it parsed the variable when the button was created, not when it was clicked.  How can I have that use the new value in the variable?

 

In addition, I had a thought of doing this:

 

<apex:commandButton id="ConfirmBtn" action="{!confirm}" oncomplete="window.location=updateRedirect();" value="Confirm" />

<apex:actionFunction name="updateRedirect" action="{!updateRedirect}" />

 and the updateRedirect method returns the redirectURL's new value, but the javascript sees it as "false".

 

I'm running out of ideas, and I understand I might be approaching this totally wrong, but I'm eager to hear solutions, or how to approach this other ways.

 

 

We're facing a problem here and I'm sure we can't be the only ones to have to tackle it.

 

The Setup:

Three Salesforce Packages in development (A, B, C).

Four developers all working on them at various times.

Package C is dependant on Package B.

Version Control is needed.

 

The Solution:

Use Eclipse to develop in, and each developer has ther own dev orgs for each project

Use SVN repositories to commit and update each other's orgs and finally the master org that packages.

Use Eclipse to edit the files and commit, update, and save.

 

The Problems:

it's rediculously tedious to set up a development environment for package C because most of the files require "version 1.1" of package B.  We're on version 3 by now, so now we have to either install version 1.1 (and every other version some file might have in the required XML) or manually change every xml file to have the actual version we have installed.  The "or higher" concept doesn't exist in this environment.

 

Also many times we'll update from svn, and it can't save to the develoment org saying the file has been changed since last save, so we'll then have to refresh from the org, then revert to the svn, and hope it saves right (and no changes were made in that org, for that example) and that happens nearly every update.

 

This also doesn't cover the issues created when svn "makes" a file in a dev org...

 

Is there a setup step or a "work properly" checkbox we're missing somewhere?  if not, is anyone else facing this issue?

 

 

We have a page that has a cripplingly slow generation time, so we have caching set to one day on a page.

 

<apex:page cache="true" expires="86400">

 We just made a major modification to one of the aspects of this page that uses an ajax call.  The values that are returned by this ajax call are not readable by the previous version of the visual force page's javascript.  This is the problem we're facing.  Elaborated more:

 

If we install the new package, the visualforce page is still going to be cached for 24 hours, but the ajax responder will send data it can't read, until the caching is over and the new version of the visualforce page is there.

 

Is there a way to cancel a web page's caching in sites?  We tried changing the site, changing the cache to false, even deactivating the site, and none of those things had any effect until the caching ran out.

 

Any advice would be welcome.

I have a hunch I'm missing something obvious, but I've finished making a flow, set as start location, saved it to make sure there were no warnings, then clicked "run" and I get:

 



Insufficient Privileges

 

You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. 

 

 

Anyone have any ideas as to what I'm doing wrong?

 

*Note:  I'm using the cloud Flow Designer. I use a mac, so I can't even try the locally run version

 

I posted a similiar issue in the VisualForce Forum, but realized this is more of an Apex issue.

 

I'm using the example for dynamic components that I found in the docs, since I need the functionality.  The concept seems perfect for my project, but the example doesn't even work.

 

I used this (exactly from the docs):

 

public Component.Apex.PageMessage getCheckDueDate() 
    { 
        Component.Apex.SectionHeader sectionHeader= new Component.Apex.SectionHeader(); 
        sectionHeader.title='This form was due on 03/06/2011!'; 
        date myDate = date.today(); 
        date dueDate = date.newInstance(2011, 3, 6); 

        boolean dueNow = myDate.isSameDay(dueDate); 

        if (!dueNow) 
        return sectionHeader; 
        else return null; 
    } 

and I get the error: 

Save error: Invalid type: Component.Apex.SectionHeader 

 

It's like it doesn't recognize the new object types.  (having the example code not work is VERY frustrating)

 

If anyone can help, I would greatly appreciate it.

I'm looking to have an object store a list of fields to be made into a form, with "type" being text, textarea, file, hidden, checkbox, etc.  I'm not sure how to best accomplish this.  I can think of two ways, but both have notable problems.

 

Option one:

define a set of boolean variables and then

<apex:inputFile rendered="{!isFile}" value="{!blahblahblah}" />
<apex:inputText rendered="{!isText}" value="{!blahblahblah}" />
<apex:inputHidden rendered="{!isHidden}" value="{!blahblahblah}" />

 

etc. (there are seven options, I believe, so you're looking at 7 boolean tests PER field, so when making a 50 field form, that's 350 boolean tests.. page loads too slow)

 

Option two:

Where the booleans above are defined, just have it actually make a string with the HTML input command, and the VF page just have something like:

<apex:repeat value="{!fieldOutputs}" var="output" id="theRepeat">
<apex:outputText escape="false" value="{!output}" /><br />
</apex:repeat>

 


That worked fine for making the page, and ran fast (because you can "else If" in apex) but now I don't have a way to get the data back to the controller when I click the save button.

 

I would greatly appreciate any help that can be offered, thanks!

 

ScriptMonkey

I'm writing an object-driven form manager, so you can make a form that you can select a field type, then link it to a salesforce object field, and when you submit, it will save the data into the SF field.

 

Here's the problem:

 

doing it using <apex:inputText (or Hidden or TextArea or File, etc) ends up being five or six boolean tests, for EVERY field (in the rendered attribute, is it text, if yes, show, then the next one, is it textarea, if yes, show, etc).  This makes the page loadtime considerably higher than I want, especially when you're looking at 50 or 60 fields.  My other alternative was to write the html in the class, then output it as an array of strings in a repeat.

 

This worked great for display, but now I'm not sure how to get the results back from the form into apex.  I'm open to suggestions, please let me know what you think?

 

 

When I load a certain visualforce page, I get "Maximum view state size limit (135KB) exceeded" and I'm not sure the steps to troubleshoot, I'm not even entirely sure of the cause.

 

I found in other forums the idea that I need to use "Transient" keywords in more variables, but I'm hoping for a way I can test to see what's using up the memory rather than just guessing, then refreshing, then guessing again.

 

I've never seen this error before, and I've not used transient before, so I'm not sure the effect it will have on the page I'm supporting.  Any pointers/support would be greatly appreciated.

 

 

I'm looking to do something of a somwhat unique nature (well I think it's unique)

 

I have two sites each linked to two different packages.  Site A (and it's package) creates a contact.

 

Site B (and it's package) attaches objects, updates it, etc.

 

When Site A creates the cotact, it is that site's guest user that is the owner.

 

I know that I can make a public group, and put the site users in it, then share it with other public groups, but using that is not letting SiteB Guest User edit/modify SiteA Guest User's contacts.

 

I'm trying to not involve triggers to modify who owns it, because then we can't track as well as we would hope.

 

I have a public group with both site users in it, and another one with just siteB's user.  Then I have two sharing rules, one is "all internal users" sharing read/write with the SiteB public group, the other is the "all sites" public group sharing read/write with the SiteB Group.

 

but it seems site B still cannot edit a contact owned by SiteA's user.

 

Advice?

 

We have a package that uses Custom Settings (protected).  The visualforce pages/classes in the package can access it fine, without problems, but the FLEX app we have in the package cannot access it.

 

Does anyone have any suggestions or advice how to let the Flex app reach the custom settings without making new ones?

 

Thanks

I am working with an export method that requires "flattening" of data, so my schema of children objects has a field "exportSequence" which is just an integer ordered by date.

 

I have triggers to update that order when a new child record is made, or deleted. but I just found out today that if contacts are merged, then the children record triggers do not fire. (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_merge_statements.htm)

 

I need a suggestion as to how to make the children object triggers fire (without looping) to reorder themselves based on the contact they're attached to.

 

Note: There are 5 objects all children to Contact, and I'm hoping to not have the global "reorder everything" trigger on the contact, that will reorder all five children objects when I only need to do one or two.

 

Thanks,

ScriptMonkey

I found this out the very hard way and I would like to share my findings to either warn others, or find out if I've done something wrong somehow.  Sobjects cannot be handed lists of objects via addAll (even though they can be added objects one at a time through add, and OTHER methods that have sObject lists as parameters can accept object lists).

I'll show by example:
Account a = new Account();
sObject s
LIST<sObject> sOjbList = new LIST<sObject>();
sOjbList.add(s);
sOjbList.add(a);
That works perfectly fine, as you'd expect.
sObject s1;
sObject s2;
LIST<sObject> sList = new LIST<sObject>{s1, s2};
LIST<sObject> sOjbList = new LIST<sObject>();
sOjbList.addAll(sList);
Also works fine.

This, however, will fail.
LIST<Account> aList = new LIST<Account>{new Account(), new Account()};
LIST<sObject> sOjbList = new LIST<sObject>();
sOjbList.addAll(aList);
It gives the errors:
Incompatible argument type LIST for All method on LIST
OR
Incompatible argument type LIST<Account> for All method on LIST<SObject>
(Based on if you're using the Developer Console or something else, like MavensMate)

But don't fret, there's a solution (albeit a silly one)
private LIST<sObject> objToSobj(sObject[] objList)
{
	return objList;
}
That's right, pass your objList through this (and it will let you without problem) and all works fine.

Thoughts?
I'm facing an issue in a package I've released that has an intermittant problem.  There are orgs with 600k contacts and this code works fine, but there is an org with 200k records and it fails with the non-selective query error.

here's the pseudocode:

[SELECT
(SELECT id from objectA),
(SELECT id from objectB)
FROM contact WHERE id IN
(SELECT Contact__c FROM objectC WHERE id IN :listOfObjIDs)]

listOfObjIDs is a list of strings that has IDs in objectC built from an after insert trigger on objectC
objectC is a child object of Contact with a field Contact__c containing its contact
Objects A and B are also children of Contact

ID in indexed, and listOfObjIDs cannot contain any null values unless you can have required fields as null in a trigger.new reference (the parent's value can't be null on a child record).

I'm looking for any advice or suggestions anyone might have, I'm usually pretty solid in SOQL but I can't understand how this is an issue in some orgs and not others.

Additional note: in the org having the problem, the only object in the entire org over 100k records is contact, the rest have less than a few thousand, so it needs to be the contact-based part of the query.

how to add image in pageblock table and can we perform action on onclick image...any plz help me out..thx in advance frds.
How to avoid Too Many Future callouts!!!!!!Help me
I want to send contact info of particler lead to my 3rd party...
dis code will fine for 9-records



my trigger is

trigger conupdater on Contact(after insert,after update,before delete)
{
    list <lead> l=[Select id,name,lastname,firstname from lead];
    BuzzBoard_Setting__c bb=[select id,Name,Partner_key__c from BuzzBoard_Setting__c Order by CreatedDate DESC LIMIT 1];
    public String mymethod;
    public String type='Contact'; 
    Map<id,id> contMap=new Map<id,id>();
  
    if(Trigger.isAfter)
    {
      for(contact cont:Trigger.new){     
         if(cont.ContactLead__c!=null){
             contMap.put(cont.id,cont.ContactLead__c);
         }
    }
 
    }  
    if((Trigger.isAfter && Trigger.isInsert))
    {
    for(contact c:Trigger.New){
        mymethod='INSERT';
        if(contMap.containsKey(c.id)){
            LeadChildsUpdater_bb.updatenotes(c.id,contMap.get(c.id),mymethod,type,bb.Partner_key__c);
        }
      
    }
    }

    if((Trigger.isAfter && Trigger.isUpdate))
    {
    for(contact c:Trigger.New){
        mymethod='UPDATE';
        if(contMap.containsKey(c.id)){
            LeadChildsUpdater_bb.updatenotes(c.id,contMap.get(c.id),mymethod,type,bb.Partner_key__c);
        }
    }
    }

    if((Trigger.isBefore && Trigger.isDelete))
    {
    for(contact cont:Trigger.old){     
         if(cont.ContactLead__c!=null){
             contMap.put(cont.id,cont.ContactLead__c);
         }
    }
    for(contact c:Trigger.Old){
        mymethod='DELETE';
        if(contMap.containsKey(c.id)){
            LeadChildsUpdater_bb.updatenotes(c.id,contMap.get(c.id),mymethod,type,bb.Partner_key__c);
        }
    }
    }
}

My Controller class is ::
 
public class LeadChildsUpdater_bb
{
public static string resmessage;
@Future(callout=true)

  public static void updatenotes(String Id,String Lead_Id,String Action,String Type,String Key)
  {
  
    HttpRequest req = new HttpRequest();
    req.setEndpoint('https://demo.mybuzzboard.com/salesforce/assetsSync.php');
    req.setMethod('POST');
    req.setBody('Id='+EncodingUtil.urlEncode(+Id, 'UTF-8')+'&Lead_Id='+EncodingUtil.urlEncode(+Lead_Id, 'UTF-8')+'&Action='+EncodingUtil.urlEncode(+Action, 'UTF-8')+'&Type='+EncodingUtil.urlEncode(+Type, 'UTF-8')+'&Key='+EncodingUtil.urlEncode(+Key, 'UTF-8'));
    Http http = new Http();
    HttpResponse res = http.send(req);
 
    if (res.getStatusCode() == 200)
    {
          
          
             System.debug('---------------------'+res.getBody());
     }
    else
     {
      System.debug('Callout failed: ' + res);
     }

}
}

I have a pretty large visualforce page that I am having people fill out.  I have set about 50 fields on it to be required like <apex:inputfield required="true" value="{!var1}">  I want the field to be required so that before they can finish the page they need to fill that field out.  I would also like to give them a "Save and Continue" button so that they can save their progress.  I want this button to bypass the required flag but it needs to pass the variable var1 to the method so that it saves it.  Then I want a second save button that enforces the required flag.  Is there anyway to do this?

I have a visualforce page that shows a child object of Contact.  I tried refrencing the contact.object__r in a visualforce page, putting it in a apex:repeat command.  This works fine when vieing /apex/VFpage, but on sites it doesn't see the values in the sub-object.

Then I tried a second SOQL statement instead, putting it in a varaible "Objects" then repeating on that.  Again, it works fine in  apex mode, but on the site, it stops working.

 

Now the really confusing part. I made a sub-class and iterated through the objects variable, setting an array of this sub-class, setting values from the objects variable, then used THAT in the Visualforce page and looped through it, and it worked fine, sites and apex both.

 

Any idea what can cause this kind of issue? It's clearly not permissions it's just weird handling in visualforce.

I've got a problem that I can't seem to resolve.  Here's my VisualForce code and Apex code.  When I uncomment out the expressions line in the Apex code, clicking the "save" button just loads the whole controller, with that line commented out, clicking save just executes the save function and triggers that two debug statements as I expect it to.

 

Any advice is very welcome, I've been staring at this all day.

 

VF:

<apex:page controller="testSaveController" showHeader="false" cache="false" 
	sidebar="false" standardStylesheets="false">
	<apex:form id="theForm">
		<apex:dynamicComponent componentValue="{!fieldDisplay}" />
		<center>
		<apex:commandButton action="{!save}" value="Save" id="theButton" rerender="theForm"/>
		</center>
	</apex:form>
</apex:page>

 

APEX:

public with sharing class testSaveController
{
	public LIST<string> fieldValues					{ get; set; }
	
	public testSaveController()
	{
		//constructor
	}
	
	public Component.Apex.OutputPanel getFieldDisplay()
	{
		fieldValues = new LIST<string>();
		fieldValues.add('testVal');
		
		Component.Apex.OutputPanel formContainer = new Component.Apex.OutputPanel();
		
		Component.Apex.InputText dynInpText = new Component.Apex.InputText();
//		dynInpText.expressions.value = '{!fieldValues[0]}';
		dynInpText.id = 'field0';
		formContainer.childComponents.add(dynInpText);

		return formContainer;
	}
	
	public void save()
	{
		system.debug('----------------------------------------------');
		system.debug(fieldValues);
	}
}

 

 

I have a hunch I'm missing something obvious, but I've finished making a flow, set as start location, saved it to make sure there were no warnings, then clicked "run" and I get:

 



Insufficient Privileges

 

You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. 

 

 

Anyone have any ideas as to what I'm doing wrong?

 

*Note:  I'm using the cloud Flow Designer. I use a mac, so I can't even try the locally run version

 

I posted a similiar issue in the VisualForce Forum, but realized this is more of an Apex issue.

 

I'm using the example for dynamic components that I found in the docs, since I need the functionality.  The concept seems perfect for my project, but the example doesn't even work.

 

I used this (exactly from the docs):

 

public Component.Apex.PageMessage getCheckDueDate() 
    { 
        Component.Apex.SectionHeader sectionHeader= new Component.Apex.SectionHeader(); 
        sectionHeader.title='This form was due on 03/06/2011!'; 
        date myDate = date.today(); 
        date dueDate = date.newInstance(2011, 3, 6); 

        boolean dueNow = myDate.isSameDay(dueDate); 

        if (!dueNow) 
        return sectionHeader; 
        else return null; 
    } 

and I get the error: 

Save error: Invalid type: Component.Apex.SectionHeader 

 

It's like it doesn't recognize the new object types.  (having the example code not work is VERY frustrating)

 

If anyone can help, I would greatly appreciate it.

I'm looking to have an object store a list of fields to be made into a form, with "type" being text, textarea, file, hidden, checkbox, etc.  I'm not sure how to best accomplish this.  I can think of two ways, but both have notable problems.

 

Option one:

define a set of boolean variables and then

<apex:inputFile rendered="{!isFile}" value="{!blahblahblah}" />
<apex:inputText rendered="{!isText}" value="{!blahblahblah}" />
<apex:inputHidden rendered="{!isHidden}" value="{!blahblahblah}" />

 

etc. (there are seven options, I believe, so you're looking at 7 boolean tests PER field, so when making a 50 field form, that's 350 boolean tests.. page loads too slow)

 

Option two:

Where the booleans above are defined, just have it actually make a string with the HTML input command, and the VF page just have something like:

<apex:repeat value="{!fieldOutputs}" var="output" id="theRepeat">
<apex:outputText escape="false" value="{!output}" /><br />
</apex:repeat>

 


That worked fine for making the page, and ran fast (because you can "else If" in apex) but now I don't have a way to get the data back to the controller when I click the save button.

 

I would greatly appreciate any help that can be offered, thanks!

 

ScriptMonkey

When I load a certain visualforce page, I get "Maximum view state size limit (135KB) exceeded" and I'm not sure the steps to troubleshoot, I'm not even entirely sure of the cause.

 

I found in other forums the idea that I need to use "Transient" keywords in more variables, but I'm hoping for a way I can test to see what's using up the memory rather than just guessing, then refreshing, then guessing again.

 

I've never seen this error before, and I've not used transient before, so I'm not sure the effect it will have on the page I'm supporting.  Any pointers/support would be greatly appreciated.

 

 

Hi,

i have applied a scroll for the pageblocktable using a outputpanel but now i want to freeze the header of the pageblock table when i do scroll. Any help would be really appreciated..

 

Hi,

I am developing an application in Force.com plateform for a while. I have already release a version too. But now I have to create  a replica of all the custom things e.g. Object,Trigger,Classes,Pages,Fields etc.in an another org. so that I can try something for experiment. Is it possible to do so? If yes, then can anyone please explain me how to do that.

 

 

Regards,

Samarjit

Get following error when generate apex class from wsdl file. Could anyone please help provide some insight? Thanks!
 
The following generated class(es) have compilation errors:
Error: inthubCrmserviceWsdl
Error: Dependent class is invalid and needs recompilation:
inthubCrmserviceTypes: line 34, column 18: inthubCrmserviceTypes.IntHubException: Exception class must extend another Exception class at 12:13
 
//Generated by wsdl2apex
public class inthubCrmserviceWsdl {
    public class CrmProcessorPort {
        public String endpoint_x = 'http://dapp1:57050//CRMService';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        private String[] ns_map_type_info = new String[]{'http://inthub.prod.netsol.com/CRMService/wsdl', 'inthubCrmserviceWsdl', 'http://inthub.prod.netsol.com/CRMService/types', 'inthubCrmserviceTypes'};
        public void submitForm(inthubCrmserviceTypes.Credential Credential_1,inthubCrmserviceTypes.FormRequest FormRequest_2) {
            inthubCrmserviceTypes.submitForm request_x = new inthubCrmserviceTypes.submitForm();
            inthubCrmserviceTypes.submitFormResponse response_x;
            request_x.Credential_1 = Credential_1;
            request_x.FormRequest_2 = FormRequest_2;
            Map<String, inthubCrmserviceTypes.submitFormResponse> response_map_x = new Map<String, inthubCrmserviceTypes.submitFormResponse>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://inthub.prod.netsol.com/CRMService/types',
              'submitForm',
              'http://inthub.prod.netsol.com/CRMService/types',
              'submitFormResponse',
              'inthubCrmserviceTypes.submitFormResponse'}
            );
            response_x = response_map_x.get('response_x');
        }
    }
}

Error: inthubCrmserviceTypes
Error: inthubCrmserviceTypes.IntHubException: Exception class must extend another Exception class at 34:18
//Generated by wsdl2apex
public class inthubCrmserviceTypes {
    public class submitForm {
        public inthubCrmserviceTypes.Credential Credential_1;
        public inthubCrmserviceTypes.FormRequest FormRequest_2;
        private String[] Credential_1_type_info = new String[]{'Credential_1','http://inthub.prod.netsol.com/CRMService/types','Credential','1','1','true'};
        private String[] FormRequest_2_type_info = new String[]{'FormRequest_2','http://inthub.prod.netsol.com/CRMService/types','FormRequest','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://inthub.prod.netsol.com/CRMService/types','false'};
        private String[] field_order_type_info = new String[]{'Credential_1','FormRequest_2'};
    }
    public class Credential {
        public String password;
        public String userName;
        private String[] password_type_info = new String[]{'password','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] userName_type_info = new String[]{'userName','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://inthub.prod.netsol.com/CRMService/types','false'};
        private String[] field_order_type_info = new String[]{'password','userName'};
    }
    public class FormRequest {
        public String action;
        public String clientRef;
        public inthubCrmserviceTypes.FormData[] formData;
        public String productInstanceId;
        public String webformInstanceId;
        private String[] action_type_info = new String[]{'action','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] clientRef_type_info = new String[]{'clientRef','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] formData_type_info = new String[]{'formData','http://inthub.prod.netsol.com/CRMService/types','FormData','0','-1','true'};
        private String[] productInstanceId_type_info = new String[]{'productInstanceId','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] webformInstanceId_type_info = new String[]{'webformInstanceId','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://inthub.prod.netsol.com/CRMService/types','false'};
        private String[] field_order_type_info = new String[]{'action','clientRef','formData','productInstanceId','webformInstanceId'};
    }
    public class IntHubException {
        public Integer errorCode;
        public String vendorErrorCode;
        public String vendorErrorMessage;
        public String message;
        private String[] errorCode_type_info = new String[]{'errorCode','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
        private String[] vendorErrorCode_type_info = new String[]{'vendorErrorCode','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] vendorErrorMessage_type_info = new String[]{'vendorErrorMessage','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] message_type_info = new String[]{'message','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://inthub.prod.netsol.com/CRMService/types','false'};
        private String[] field_order_type_info = new String[]{'errorCode','vendorErrorCode','vendorErrorMessage','message'};
    }
    public class submitFormResponse {
        private String[] apex_schema_type_info = new String[]{'http://inthub.prod.netsol.com/CRMService/types','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class FormData {
        public String answer;
        public String name;
        public String question;
        private String[] answer_type_info = new String[]{'answer','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] name_type_info = new String[]{'name','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] question_type_info = new String[]{'question','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://inthub.prod.netsol.com/CRMService/types','false'};
        private String[] field_order_type_info = new String[]{'answer','name','question'};
    }
}
I have a custom object LeadCompany__c to associate related leads.

Can I use dot notation to pull a list of all leads associated with my custom object, rather than use an SOQL query?

Currently, I must use the following query:

List<Lead> Lds = [SELECT ID FROM Lead WHERE LC_Lead_Company__c = :ld.LC_Lead_Company__c];

Would it be possible to get this information without an SOQL query in the following manner:

List<Lead> leads = ld.LC_Lead_Company__c.Leads;
 
  • December 30, 2014
  • Like
  • 1