• adampro
  • NEWBIE
  • 50 Points
  • Member since 2011

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

Hi-

 

I created two pages that use the same controller, and I want each to pass a parameter to the controller so I can handle each page accordingly. However, I can't seem to figure out how to pass the paramter to the controller.

 

I have the page set up like so:

<apex:page standardController="Contact" extensions="SharedController" showHeader="false" action="{!Redirect}">
    <apex:param name="childToClone" value="1" assignTo="{!childToClone}"/>
</apex:page>

 And I set the controller up like so:

public with sharing class SharedController {

   public PageReference Redirect() {
      string childToClone = ApexPages.currentPage().getparameters().get('childToClone');

      // MORE CODE HERE
   }
}

 

I tried printing the keys in the parameters map and it returned <id, scontrolcaching>. Any ideas?

Hi,

 

I'm designing a survey page where every question has two possible answers, and the user is only allowed to select one. I want to make it so that when a box is set true, it will turn the other one false to ensure only one box for that question is checked. Can anyone think of a good way of doing this?

 

Is there a way to call a method after the box has been set true? I know you can re-render page blocks but I don't think that helps here.

 

 

Thanks!

Do you know why this keeps happening? I'm trying to design this page and I keep running into this. I've changed my approach at least 3 times and yet I keep coming back to it. The basic idea is I'm creating a survey of T/F questions. I am setting up a method each box will call to ensure only 1 box for each question is checked. Here's my code:

 

<apex:page controller="surveyController">
<apex:form id="form">
    
    <apex:sectionHeader title="Assessment" subtitle="SCP Support Standard Self-Assessment Sampling">
    <description>
        This sampling of the self-assessment will help you determine how your organization measures up <br/>
        to the SCP standards and introduces you to a sampling of elements within the program.
        <ul>
            <li>Answer either "YES" or "NO" to each of the following questions. If you do not know or <br/>
            are unsure, you should answer "NO".
            </li>
            
        </ul>
    </description>
    </apex:sectionHeader>
    
    <br></br>
    
    <apex:pageBlock id="followObjectBlock" title="Part 1">
        <br/>
        Yes No
        <br/>
        <br/>
        
        <apex:outputPanel id="Question1">
        <apex:inputCheckbox id="Q1True" value="{!checkQ1True()}"/>
        <apex:inputCheckbox id="Q1False" value="{!checkQ1False()}"/>
        
        1. Question 1
        </apex:outputPanel>
        <br/>
        <br/>
        <apex:inputCheckbox id="Q2True"/>
        <apex:inputCheckbox id="Q2False"/>
        2. Question 2
        <br></br>
        <br></br>
        
        <apex:inputCheckbox id="Q3True"/>
        <apex:inputCheckbox id="Q3False"/>
        3. Question 3
        <br></br>
        <br></br>
        <apex:commandButton id="CreateButton" value="Save" action="{!submitResults}"/>
        
    </apex:pageBlock>
</apex:form>
</apex:page>

 

public with sharing class surveyController {

    public Boolean Q1True {get;set;}
    public Boolean Q1False {get;set;}
    public Boolean Q2True {get;set;}
    public Boolean Q2False {get;set;}
    public Boolean Q3True {get;set;}
    public Boolean Q3False {get;set;}
    

    public void checkQ1True() {
        Q1False = false;
    }
    
    public void checkQ1False() {
        Q1True = false;
    }
    
    
    public void submitResults() {
        
        Survey_Response__c newResult = new Survey_Response__c(Question_1__c = Q1True);
        insert newResult;
        
    }

}

 

Hi,

 

I'm creating an email service, but I can't seem to get it to include the attachments. I've found plenty of example code on this yet somehow it's not working. It will create a task like I want it to, but it never associates the attachments.

 

Task[] newTask = new Task[0];

newTask.add( new Task (
                Subject = subject,
                OwnerId = matchUpp.OwnerId,
                Type = 'Email',
                ActivityDate = system.now().date(),
                Status = 'Completed',
                Description = BodyText,
                Priority = 'Normal',
                WhatId = matchOpp.Id
                )
);
                
insert newTask;

if ( email.binaryAttachments != null && email.binaryAttachments.size() > 0 ) {
    for (Messaging.Inboundemail.Binaryattachment bAttachment : email.binaryAttachments ) {
        /*
        Attachment attachment = new Attachment();
        attachment.Name = bAttachment.fileName;
        attachment.Body = bAttachment.body;
        attachment.ParentId = newTask[0].Id;
            	
        insert attachment;
        */
        Attachment a = new Attachment(ParentId = newTask[0].Id, 
                                          Name = bAttachment.filename, 
                                          Body = bAttachment.body);
            		insert a;
            	}
        }
            
if (email.textAttachments != null && email.textAttachments.size() > 0) {
            	for (Messaging.Inboundemail.Textattachment tAttachment : email.textAttachments ) {

    /*
    Attachment attachment = new Attachment();
    attachment.Name = tAttachment.fileName;
    attachment.Body = blob.valueOf(tAttachment.Body);
    attachment.ParentId = newTask[0].Id;
            	
    insert attachment;
    */
            		
    Attachment a = new Attachment(ParentId = newTask[0].Id, 
                                          Name = tAttachment.filename, 
                                          Body = blob.valueOf(tAttachment.body));
    insert a;
    }
}

 

For whatever reason, this won't seem to work. I've tried attaching .txt, .jpg, and .png files and none have shown up. Does anyone see something I'm doing wrong?

 

Thanks

Hi,

 

I'm making a pageBlockTable to display a list of custom objects. However, there are times where there won't be any objects to display. Is there any way I can make it show that there are no objects returned in the query, rather than it just being a blank table?

 

I tried this to populate the list with an object that would display 'No records to display', but it returned an error saying : "Error: PartExtension Compile Error: Variable does not exist: Name at line 29 column 52" 

 

(line 29 is the line displayed below)

 

else{
                objectsList.add( new Custom_Object__c (Name = 'No records to display'));
            }

 

What other options do I have?

Hi,

 

I'm trying to create a custom Detail Page button on Accounts that will re-direct to a custom Visualforce page I made. On the VF page I need the Account Id from the previous page in order to query some information on it. How do I do this?

 

Thanks!

  • September 28, 2011
  • Like
  • 0

Hi,

 

I'm populating a list of all of the different objects in a respective org and returning those names to a selectList. When I retrieve the list of all the objects, they are in a random, non-alphabetical order so when they appear on the VFP it's hard to find what you're looking for. I want to sort the list of SelectOptions in alphabetical order but I can't use the sort() method on the list because it doesn't support SelectOptions.

 

Is there some kind of function for organizing a list of SelectOptions?

Hi,

 

I'm trying to create an ApexTrigger using the Metadata API. I have the trigger populated with data but I'm having trouble deploying it. I know I need to convert the ApexTrigger to byte[] but don't know how.

 

I tried:

String s = trigger.ToString();
System.Text.ASCIIEncoding encode = new System.Text.ASCIIEncoding();
byte[] bytes = encode.GetBytes(s);

but that doesn't work since ToString() only retrieves the name of the trigger, not the entire thing.

 

Does anyone know how to do this?

 

Thanks. 

Hi,

 

I'm trying to create a validation rule to prevent the Status (which is a picklist field) from being changed once it's set to "Closed". I tried:

 

PRIORVALUE( Status__c) = "Completed"

 but apparently I can't compare the picklist value to a string like that. I also thought about using ISPICKVAL() but that takes in a field, not an actual value like PRIORVALUE would return.

 

Any suggestions?

Hi,

 

Does anyone know how/have any advice for using the Metadata WSDL in Python? I know I'm going to have ot use beatbox but I don't know much more than that. I'm trying to use it to create ApexTrigger sObjects. Any help will be very much appreciated.

 

Thanks!

Hi,

 

I'm trying to use Beatbox because I have to utilize the metadata WSDL file for what I'm trying to accomplish but right now I'm having trouble even getting started. Right now, it's not even allowing me to login. This is the code I'm using, direct from the Beatbox page: 

 

sf = beatbox._tPartnerNS
svc = beatbox.Client()
svc.login(username@gmail.com, PasswordwithSecurityTokenAppended)

 

First I tried using GetPass to enter my password but that kept returning me an error so I decided to scrap that and just try entering my Password+security token directly into the code. Of course, this time it's returning me a different error. 

 

File "build/bdist.macosx-10.6-intel/egg/beatbox.py", line 55, in login
    lr = LoginRequest(self.serverUrl, username, password).post()
  File "build/bdist.macosx-10.6-intel/egg/beatbox.py", line 307, in post
    raise SoapFaultError(faultCode, faultString)
SoapFaultError: 'INVALID_LOGIN' 'INVALID_LOGIN: Invalid username, password, security token; or user locked out.'

 

I know for certain that my username, password, and security token for my Dev account are all correct. Does anyone know what is wrong and/or how I can go about fixing this?

 

Thanks!

I'm trying to create a trigger that will fire on the insert/update of any object a User selects from a picklist in a custom VF page I made. Because it could be any object (either custom or standard), I can't just build a trigger the standard way. What I'm assuming is I'm going to have to pass the data into a class/function and that function will create the trigger. I've been looking around but I can't find a way to build a trigger within a class filled with the rest of the necessary data I need to populate the trigger. Is this even possible? If so, can someone point me in the right direction on this?

 

Thanks!

I'm currently writing a Visualforce page that prompts the user to select an object in their org, and then choose a field from that object. I've found a way to compile the list of objects without any trouble, but I'm struggling to compile a list of the fields belonging to that object. When the user selects an object, I store the object name as a string. I can find the fields for a designated object using the code below:

 

Map<String, Schema.SobjectField> M = Schema.SObjectType.Account.fields.getMap();
            
List<Schema.SObjectField> resultList = M.values();

 

However, I can't seem to use that code to display the fields of every object. The object name goes where it says "Account" but when I try using the string name for the object that was selected, it throws me an error message. I can't find a way to reference any object without manually typing the name in. I know I need to either convert the string name to some other sort of data type or come up with a new algorithm altogether.

 

Does any one have any suggestions?

Hi,

 

I have field on opportunity object called delivery date which is lookup of a custom object (Equipments__c)'s delivery date.

I need to query on opportunity object where delivery date is in the past(is crossed).

 

I have written the query as:

 

List<Opportunity> oppList = [select id from Opportunity o where Equipments__r.Delivery_date__c < today];

 

I am getting the issue as below:

 

"Didn't understand relationship 'Equipments__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name."

 

I am not sure where the issue is. Please help me in identifying the issue.

 

Thanks,

JBabu.

 

 

  • May 10, 2012
  • Like
  • 0

How will  i set and map  methods this trigger?

 

 

trigger Inventorybid on bid__c (after update) {
List<id> accIds=new List<id>();
 double sumTotal = 0;
  List<servoTerra_Order__c>  OrderUpdate = new List<servoTerra_Order__c>();
    for (bid__c bidoffer : Trigger.new){
    for (servoTerra_Order__c ord  : [select Id, Name, total__c from servoTerra_Order__c where Id=:bidoffer.Order__c])
    {
    //Sum all the Total offer
    for (bid__c bidtotal: [select Id,name,Total_Offer__c from bid__c where Order__c =:ord.id])
   {
    sumTotal += bidtotal.Total_Offer__c;   
    }
    ord.total__c = sumTotal;
    OrderUpdate.add(ord);
    }
   }
    
  upsert OrderUpdate;
     
}

 

 

Update failed. First exception on row 0 with id a0TV00000003akPMAQ; first error:

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Inventorybid: execution of

AfterUpdate caused by: System.ListException: Duplicate id in list:

a0UV0000000qI8nMAE Trigger.Inventorybid: line 33, column 1: []

Hi,

 

I'm designing a survey page where every question has two possible answers, and the user is only allowed to select one. I want to make it so that when a box is set true, it will turn the other one false to ensure only one box for that question is checked. Can anyone think of a good way of doing this?

 

Is there a way to call a method after the box has been set true? I know you can re-render page blocks but I don't think that helps here.

 

 

Thanks!

Do you know why this keeps happening? I'm trying to design this page and I keep running into this. I've changed my approach at least 3 times and yet I keep coming back to it. The basic idea is I'm creating a survey of T/F questions. I am setting up a method each box will call to ensure only 1 box for each question is checked. Here's my code:

 

<apex:page controller="surveyController">
<apex:form id="form">
    
    <apex:sectionHeader title="Assessment" subtitle="SCP Support Standard Self-Assessment Sampling">
    <description>
        This sampling of the self-assessment will help you determine how your organization measures up <br/>
        to the SCP standards and introduces you to a sampling of elements within the program.
        <ul>
            <li>Answer either "YES" or "NO" to each of the following questions. If you do not know or <br/>
            are unsure, you should answer "NO".
            </li>
            
        </ul>
    </description>
    </apex:sectionHeader>
    
    <br></br>
    
    <apex:pageBlock id="followObjectBlock" title="Part 1">
        <br/>
        Yes No
        <br/>
        <br/>
        
        <apex:outputPanel id="Question1">
        <apex:inputCheckbox id="Q1True" value="{!checkQ1True()}"/>
        <apex:inputCheckbox id="Q1False" value="{!checkQ1False()}"/>
        
        1. Question 1
        </apex:outputPanel>
        <br/>
        <br/>
        <apex:inputCheckbox id="Q2True"/>
        <apex:inputCheckbox id="Q2False"/>
        2. Question 2
        <br></br>
        <br></br>
        
        <apex:inputCheckbox id="Q3True"/>
        <apex:inputCheckbox id="Q3False"/>
        3. Question 3
        <br></br>
        <br></br>
        <apex:commandButton id="CreateButton" value="Save" action="{!submitResults}"/>
        
    </apex:pageBlock>
</apex:form>
</apex:page>

 

public with sharing class surveyController {

    public Boolean Q1True {get;set;}
    public Boolean Q1False {get;set;}
    public Boolean Q2True {get;set;}
    public Boolean Q2False {get;set;}
    public Boolean Q3True {get;set;}
    public Boolean Q3False {get;set;}
    

    public void checkQ1True() {
        Q1False = false;
    }
    
    public void checkQ1False() {
        Q1True = false;
    }
    
    
    public void submitResults() {
        
        Survey_Response__c newResult = new Survey_Response__c(Question_1__c = Q1True);
        insert newResult;
        
    }

}

 

Hi,

 

I'm creating an email service, but I can't seem to get it to include the attachments. I've found plenty of example code on this yet somehow it's not working. It will create a task like I want it to, but it never associates the attachments.

 

Task[] newTask = new Task[0];

newTask.add( new Task (
                Subject = subject,
                OwnerId = matchUpp.OwnerId,
                Type = 'Email',
                ActivityDate = system.now().date(),
                Status = 'Completed',
                Description = BodyText,
                Priority = 'Normal',
                WhatId = matchOpp.Id
                )
);
                
insert newTask;

if ( email.binaryAttachments != null && email.binaryAttachments.size() > 0 ) {
    for (Messaging.Inboundemail.Binaryattachment bAttachment : email.binaryAttachments ) {
        /*
        Attachment attachment = new Attachment();
        attachment.Name = bAttachment.fileName;
        attachment.Body = bAttachment.body;
        attachment.ParentId = newTask[0].Id;
            	
        insert attachment;
        */
        Attachment a = new Attachment(ParentId = newTask[0].Id, 
                                          Name = bAttachment.filename, 
                                          Body = bAttachment.body);
            		insert a;
            	}
        }
            
if (email.textAttachments != null && email.textAttachments.size() > 0) {
            	for (Messaging.Inboundemail.Textattachment tAttachment : email.textAttachments ) {

    /*
    Attachment attachment = new Attachment();
    attachment.Name = tAttachment.fileName;
    attachment.Body = blob.valueOf(tAttachment.Body);
    attachment.ParentId = newTask[0].Id;
            	
    insert attachment;
    */
            		
    Attachment a = new Attachment(ParentId = newTask[0].Id, 
                                          Name = tAttachment.filename, 
                                          Body = blob.valueOf(tAttachment.body));
    insert a;
    }
}

 

For whatever reason, this won't seem to work. I've tried attaching .txt, .jpg, and .png files and none have shown up. Does anyone see something I'm doing wrong?

 

Thanks

Hi,

 

I'm making a pageBlockTable to display a list of custom objects. However, there are times where there won't be any objects to display. Is there any way I can make it show that there are no objects returned in the query, rather than it just being a blank table?

 

I tried this to populate the list with an object that would display 'No records to display', but it returned an error saying : "Error: PartExtension Compile Error: Variable does not exist: Name at line 29 column 52" 

 

(line 29 is the line displayed below)

 

else{
                objectsList.add( new Custom_Object__c (Name = 'No records to display'));
            }

 

What other options do I have?

Hi,

 

I'm trying to create a validation rule to prevent the Status (which is a picklist field) from being changed once it's set to "Closed". I tried:

 

PRIORVALUE( Status__c) = "Completed"

 but apparently I can't compare the picklist value to a string like that. I also thought about using ISPICKVAL() but that takes in a field, not an actual value like PRIORVALUE would return.

 

Any suggestions?

Hi,

 

Does anyone know how/have any advice for using the Metadata WSDL in Python? I know I'm going to have ot use beatbox but I don't know much more than that. I'm trying to use it to create ApexTrigger sObjects. Any help will be very much appreciated.

 

Thanks!

Hi,

 

I'm trying to use Beatbox because I have to utilize the metadata WSDL file for what I'm trying to accomplish but right now I'm having trouble even getting started. Right now, it's not even allowing me to login. This is the code I'm using, direct from the Beatbox page: 

 

sf = beatbox._tPartnerNS
svc = beatbox.Client()
svc.login(username@gmail.com, PasswordwithSecurityTokenAppended)

 

First I tried using GetPass to enter my password but that kept returning me an error so I decided to scrap that and just try entering my Password+security token directly into the code. Of course, this time it's returning me a different error. 

 

File "build/bdist.macosx-10.6-intel/egg/beatbox.py", line 55, in login
    lr = LoginRequest(self.serverUrl, username, password).post()
  File "build/bdist.macosx-10.6-intel/egg/beatbox.py", line 307, in post
    raise SoapFaultError(faultCode, faultString)
SoapFaultError: 'INVALID_LOGIN' 'INVALID_LOGIN: Invalid username, password, security token; or user locked out.'

 

I know for certain that my username, password, and security token for my Dev account are all correct. Does anyone know what is wrong and/or how I can go about fixing this?

 

Thanks!

Is there any tool(like example Ajax tool etc) to extract the list of fields in opportunity for a particular record type

 

or

 

Is there any other way, simpler way of extracting that manually ?

  • July 08, 2011
  • Like
  • 0

I'm trying to create a trigger that will fire on the insert/update of any object a User selects from a picklist in a custom VF page I made. Because it could be any object (either custom or standard), I can't just build a trigger the standard way. What I'm assuming is I'm going to have to pass the data into a class/function and that function will create the trigger. I've been looking around but I can't find a way to build a trigger within a class filled with the rest of the necessary data I need to populate the trigger. Is this even possible? If so, can someone point me in the right direction on this?

 

Thanks!

I'm currently writing a Visualforce page that prompts the user to select an object in their org, and then choose a field from that object. I've found a way to compile the list of objects without any trouble, but I'm struggling to compile a list of the fields belonging to that object. When the user selects an object, I store the object name as a string. I can find the fields for a designated object using the code below:

 

Map<String, Schema.SobjectField> M = Schema.SObjectType.Account.fields.getMap();
            
List<Schema.SObjectField> resultList = M.values();

 

However, I can't seem to use that code to display the fields of every object. The object name goes where it says "Account" but when I try using the string name for the object that was selected, it throws me an error message. I can't find a way to reference any object without manually typing the name in. I know I need to either convert the string name to some other sort of data type or come up with a new algorithm altogether.

 

Does any one have any suggestions?

Has anybody been able to use the Metadata API using C# .net? I downloaded the Enterprise and Metadata WSDL and added them as a reference to my application. However, I can't seemt to get it to work. If anyone has any sample codes or sample programs written in C# that uses the MetaData API I would greatly appreciate it!

 

 

 

Hi All,

I am getting an error while trying to add web reference in visual studio 2005:

 

The document at the url file:///C:/Users/Emil Kalin/Desktop/enterprize.wsdl was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'DISCO Document' is 'Data at the root level is invalid. Line 2, position 1.'.
- Report from 'WSDL Document' is 'There is an error in XML document (2, 1).'.
  - Data at the root level is invalid. Line 2, position 1.
- Report from 'XML Schema' is 'Data at the root level is invalid. Line 2, position 1.'.

 

and also:

Invalid at the top level of the document. Error processing resource 'file:///C:/Users/Emil Kalin/Desktop/enterprize.wsdl'. ...

<?xml version="1.0" encoding="UTF-8" ?>

Has any one any idea? I have generated an enterprise WSDL file and copies all its content

from the browser window with the WDSL xml file.

 

The begining of the file:

<?xml version="1.0" encoding="UTF-8" ?>
- <!--
Salesforce.com Enterprise Web Services API Version 20.0
Generated on 2011-01-05 14:16:48 +0000.

Package Versions:
Aspira XObject (Version: 1.20, Namespace: aspirax)
PRM (Version: 1.2, Namespace: xforce_prm)
Salesforce for Google AdWords (Version: 1.2, Namespace: sfga)
CountryComplete (Version: 1.2, Namespace: pw_cc)
iCalendar Export (Version: 1.4, Namespace: icalendar)

Copyright 1999-2011 salesforce.com, inc.
All Rights Reserved


  -->
 <definitions targetNamespace="urn:enterprise.soap.sforce.com" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:enterprise.soap.sforce.com" xmlns:fns="urn:fault.enterprise.soap.sforce.com" xmlns:ens="urn:sobject.enterprise.soap.sforce.com">
 <types>
 <schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:sobject.enterprise.soap.sforce.com">
  <import namespace="urn:enterprise.soap.sforce.com" />
- <!--  Base sObject (abstract)
  -->
- <complexType name="sObject">
- <sequence>
  <element name="fieldsToNull" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="unbounded" />
  <element name="Id" type="tns:ID" nillable="true" />
  </sequence>
  </complexType>
- <complexType name="AggregateResult">
- <complexContent>
- <extension base="ens:sObject">
- <sequence>

 

Thank you all!

 

Code:
            var rebateTrigger = new ApexTrigger();
            rebateTrigger.apiVersion = 14.0;
            rebateTrigger.fullName = "Contact.OnUpdateRebateContact";
            rebateTrigger.content = GetResourceFile("SourceCodes.ContactRebateUpdateTrigger.txt");
            
            metaApi.create(new[] { rebateTrigger });

That is how I try to add a trigger. 
But why do I receive
INVALID_TYPE: This type of object is not available for this organization 
?

SourceCodes.ContactRebateUpdateTrigger.txt contains trigger source code that is correct. I take its source code and cast it to byte[] to assign to content property.
Help please.

PS. I have a namespace prefix set in my organization. Maybe that's the case?



Message Edited by Doker on 11-30-2008 01:55 PM
  • November 30, 2008
  • Like
  • 0