• dblaze
  • NEWBIE
  • 0 Points
  • Member since 2012

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

Hi Everyone,

I am trying to create a form wizard that allows users to submit Travel Request information.  We have 7 different travel request types that each have their own record type.  This functionality works correctly using the Case object, but when I try using our Travel_Request__c custom object it is not saving the record.  Any help would be greatly appreciated !!  Listed below is my controller

 

public class TravelRequestController {
    public Travel_Request__c newtravelrequest {get;set;}
    public String recordtype{get;set;}
    public String AccPC{get;set;}
    public String CaseOrigin = 'Web';
    
    public TravelRequestController() {
      newtravelrequest = new Travel_Request__c();
}  
    
    //Submits the Travel Request   
    public PageReference SubmitTravelRequest() {
        
        //Query for the Case record types
        List<RecordType> rTypes = [SELECT Id FROM RecordType WHERE Name = :recordtype and isActive=true];
            if(!rTypes.isEmpty())  {
            //Id accid;
            //Decimal decpc = decimal.valueOf(AccPC);      
            newtravelrequest.recordtypeId=rTypes[0].Id; 
            
/* ****** CURRENT LOCATION ******     
       //Current Location
       List<Account> lcc = [select id, Name, PC__c from Account where PC__c = :decpc];    
           if (null!=lcc && lcc.size()>0)
               {
            accid = lcc[0].id;
            newtravelrequest.AccountId = accid;
            }  

    //Sets New Location for drop down menu
    newtravelrequest.New_Location__c = NewPC;
*/    
  
    try
    {         
      insert newtravelrequest; // inserts the new travel request into the database
      newtravelrequest = new Travel_Request__c();        
    }
    catch(DmlException ex){
        ApexPages.addMessages(ex);
    }    
    }      
        PageReference travelrequest = new PageReference('/apex/CaseConfirmation'); 
        travelrequest.setRedirect(true);

    return travelrequest;
    }
}

 and here is the visualforce page

 

<apex:page Controller="TravelRequestController" tabStyle="Account" sidebar="false" showHeader="false">
<apex:sectionHeader title="HHS Receptionists" subtitle="Submit A Travel Request"/>
    <apex:form id="myForm">
        <apex:pageBlock title="Travel Request: Flight and Lodging">
            <apex:pageBlockButtons location="bottom">
                     <!--<apex:commandButton action="{!SubmitTravelRequest}" value="Submit Travel Request" immediate="true"/> -->

                    <apex:actionStatus id="actionstatus">
                        <apex:facet name="start">
                            <apex:commandButton value="Processing..." disabled="true" />
                        </apex:facet>
                        
                        <apex:facet name="stop">
                            <apex:commandButton id="SubmitButton" action="{!SubmitTravelRequest}" value="Submit Request" status="actionstatus" reRender="myForm">           
                                <apex:param assignTo="{!newtravelrequest.recordtype}" name="rtype" value="Flight_Lodging" id="rtype"/>
                            </apex:commandButton>                       
                        </apex:facet>
                    </apex:actionStatus>  
            </apex:pageBlockButtons>
             <apex:messages style="color:#FF0000;"/>     
        <table>
            <tr>
                <th>Your Name: </th>
                <td><apex:inputField required="true" value="{!newtravelrequest.Check_In_Date__c}"/></td>
            </tr>           
                </table>
         </apex:pageBlock>                
    </apex:form>
</apex:page>

 

 here is the query for the working record type query on the case object

List<RecordType> rTypes = [SELECT Id FROM RecordType WHERE Name = :recordtype and sObjectType='Case' and isActive=true];
            if(!rTypes.isEmpty())  {
            Id accid;
            Decimal decpc = decimal.valueOf(AccPC);      
            newcase.recordtypeId=rTypes[0].Id; 

 I tried it with sObjectType='Travel_Request__c but that did not work so I removed it to see if that would resolve it but that made no difference.

 

Thank you in advance for your help!!

  • August 15, 2013
  • Like
  • 0

Hi Everyone,

I am trying to create a trigger that updates a field (Passed_Test_Count__c on the Employee__c Object.  It will update the field by adding +1 each time another field Passed_Date__c on the Team_Member_Test_Result__c changes from null to an actual date.  Listed below is my code, any help is greatly appreciated!

 

 

trigger PassedTestCounter on Team_Member_Test_Result__c (after insert, after update) {
{
Map<Id,Id> TeamMemberResultsMap = new Map<Id,Id>();
for(Team_Member_Test_Result__c A : trigger.new)
TeamMemberResultsMap.put(A.Passed_Date__c,A.Id);

List<Employee__c> EmployeeToUpdate = new List<Employee__c>{};

for (Employee__c Employee: [SELECT Id,Passed_Test_Count__c FROM Employee__c WHERE Id IN: TeamMemberResultsMap.keySet()])
{
Id empId = TeamMemberResultsMap.get(EmployeeToUpdate.Id);
Employee__c emp = trigger.newMap.get(empId);

boolean transition = trigger.IsInsert || (trigger.isUpdate && trigger.oldMap.get(emp.Id).Passed_Date__c != emp.Passed_Date__c);
if (emp.Passed_Date__c != null){
EmployeeToUpdate.Passed_Test_Account__c = EmployeeToUpdate.Active_Count__c.Passed_Test_Account__c + 1 ;
EmployeeToUpdate.add(EmployeeToUpdate);
}else if (emp.Passed_Date__c == 'null') {
EmployeeToUpdate.Active_Count__c = EmployeeToUpdate.Active + 0;
EmployeeToUpdate.add(Employee);
}
}
if(EmployeeToUpdate.Active_Count__c != null && !EmployeeToUpdate.Active_Count__c.isEmpty())
Database.update(EmployeeToUpdate.Active_Count__c);
}
}

 

 

 

Thank you!!

Hi Everyone,

In a nut shell, what I am trying to accomplish is to display a list of records (Employees) on a visualforce page which is similar to this Opportunities Example - Editing Records with List Controllers.  When the user makes edits to the picklist values, they will click Save and that will then update all of the records with their changes.

 

That being said, listed below is my visualforce page and apex class. 

VF Page

<apex:page Controller="TMEvaluationClass" tabStyle="Account" sidebar="false" showHeader="false">
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!Employees}" var="emp">
                <apex:column headerValue="Account">
                    <apex:outputField value="{!emp.Account__c}"/>
                </apex:column>
                <apex:column headerValue="Employee ID">
                    <apex:outputField value="{!emp.EMP_ID__c}"/>
                </apex:column>
                <apex:column headerValue="Hire Date">
                    <apex:outputField value="{!emp.HIRE_DATE__c}"/>
                </apex:column>
                <apex:column headerValue="Tenure">
                    <apex:outputField value="{!emp.Tenure__c}"/>
                </apex:column>
                <apex:column value="{!emp.name}"/>
                <apex:column headerValue="Quality">
                    <apex:inputField value="{!emp.Q2_Quality_Rating__c}"/>
                </apex:column>
                <apex:column headerValue="Customer Satisfaction">
                    <apex:inputField value="{!emp.Q2_Customer_Sat_Rating__c}"/>
                </apex:column>                
                <apex:column headerValue="Score">
                    <apex:inputField value="{!emp.Q2_2013_TM_Eval_Score__c}"/>
                </apex:column> 
            </apex:pageBlockTable>      
        </apex:pageBlock>
    </apex:form>
</apex:page>

 Class

public class TMEvaluationClass 
{
    
    public TMEvaluationClass() {
    }
  
        //Get Employees
        public List<Employee__c> getEmployees()

        {
            List<Employee__c> Employees = new List<Employee__c>();
            Employees = [select ID, name, SS__c, Active__c, Account__c, EMP_ID__c, Hire_Date__c, Tenure__c, Q2_Customer_Sat_Rating__c, Q2_Quality_Rating__c, Q2_2013_TM_Eval_Score__c FROM Employee__c WHERE Active__c = TRUE];
            return Employees;
    }

    //Save / Update Employee Object Records
    public PageReference save() {
        /*
        try {
            update Employees;
            Employees = null;
        } catch (Exception e) {
            ApexPages.addMessages(e);
        }
        */
        return null;
    }

}

 

Currently the visualforce page is working as expected, displaying the list with all of the picklist fields that are editable but I am having trouble writing the save method in a way that will update the records rather than insert new ones.  Any advice assistance would be greatly appreciated, thank you for your time!

  • April 26, 2013
  • Like
  • 0

Hi Everyone,

As of right now I have a trigger that works exactly how I want it too but I am not able to get the test coverage working so that I can push it to production.  Can anyone help?  Below is the code for my trigger and my test coverage as it stands now...

 

Trigger

trigger AssignmentSubmitForApproval on lmscons__Transcript_Line__c (after update) {

for (Integer i = 0; i < Trigger.new.size(); i++) {

if (Trigger.old[i].lmscons__Percent_Complete__c == 0 && Trigger.new[i].lmscons__Percent_Complete__c == 100) {

// create the new approval request to submit
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setComments('Submitted for approval. Please approve.');
req.setObjectId(Trigger.new[i].Id);
// submit the approval request for processing
Approval.ProcessResult result = Approval.process(req);
// display if the reqeust was successful
System.debug('Submitted for approval successfully: '+result.isSuccess());
}
}
}

 

 

Test Coverage

@isTest
private class TestAssignmentSubmitForApproval {

static testMethod void MyUnitTest() {
lmscons__Transcript_Line__c lms = new lmscons__Transcript_Line__c();

lms.lmscons__Percent_Complete__c = 0;
//lms.lmscons__Transcript__c = lms.Id;
//lms.lmscons__Training_User_License__c = lms.id;

// insert the new lms
insert lms;
// change the probability of the lms so the trigger submits it for approval
lms.lmscons__Percent_Complete__c = 100;
// update the lms which should submit it for approval
update lms;
}
}

 

Note: the Transcript and User Liscensce fields are Master-Detail

 

Any help would be greatly appreciated!!

 

  • December 19, 2012
  • Like
  • 0

Hi Everyone,

After banging my head against the desk repetedely for the past few days I decided to see if any of you wonderful people in the community could help me out with an issue I am having.  A little backstory....my project has two pages, the first to select a recipe and then the second to pass recipe yield multiplier with the recipe Id to the second visualforce page that pulls the ingredients.  On this second visualforce page, I want the value they enter (that gets passed to the next page) double, triple, etc the ingredients actual amount.  For example: to make an egg sandwich, the base yield requires one egg.  To make three egg sandwiches, (Base 1) * (Multiplier 3 )=3

 

Listed below is the output based on the parameters passed in the url:

 

3.0 * 123 Cup Onions 1/4" Diced
3.0 * 123 Cup Green Bell Pepper 1/4" Diced
9.0 * 123 Cup Scramble Egg Mix
3.0 * 123 Cup Cheddar Cheese, Shredded

 

123 is what I am passing from the first page, and the * is added into the apex repeat

 

<apex:pageBlock title="Multiplied Ingredients">
<apex:repeat value="{!Ingredients}" var="Ingredient">
<tr>
<td align="right"> 
<apex:outputText value="!Ingredient.Amount__c} * {!YieldMultiplier}"/></td>
<td align="right"><apex:outputField value="{!Ingredient.Unit__c}"/></td>
<td align="right">
<apex:outputField value="!Ingredient.Ingredient__c}"/></td><br/>
</tr>
</apex:repeat>
</apex:pageBlock> 

 and here is the query

public string YieldMultiplier {get;set;}

//Get Ingredients
public List<Ingredients__c> getIngredients()

     {
List<Ingredients__c> outIngredients = new List<Ingredients__c>();
            outIngredients = [select Unit__c, Amount__c, Ingredient__c, Recipe__c, Multiplied_Amount__c 
FROM Ingredients__c 
WHERE Recipe__c = : ApexPages.currentPage().getParameters().get('id')];
            
for (Ingredients__c ar : outIngredients)  {
     
// ar.Amount__c = decimal.valueOf(ar.Amount__c) *= YieldMultiplier;
// not sure if this is needed       
     }
     return outIngredients;

}

 Any help would be greatly appreciated!!

  • October 19, 2012
  • Like
  • 0

Hi Everyone,

I am trying to create a trigger that updates a field (Passed_Test_Count__c on the Employee__c Object.  It will update the field by adding +1 each time another field Passed_Date__c on the Team_Member_Test_Result__c changes from null to an actual date.  Listed below is my code, any help is greatly appreciated!

 

 

trigger PassedTestCounter on Team_Member_Test_Result__c (after insert, after update) {
{
Map<Id,Id> TeamMemberResultsMap = new Map<Id,Id>();
for(Team_Member_Test_Result__c A : trigger.new)
TeamMemberResultsMap.put(A.Passed_Date__c,A.Id);

List<Employee__c> EmployeeToUpdate = new List<Employee__c>{};

for (Employee__c Employee: [SELECT Id,Passed_Test_Count__c FROM Employee__c WHERE Id IN: TeamMemberResultsMap.keySet()])
{
Id empId = TeamMemberResultsMap.get(EmployeeToUpdate.Id);
Employee__c emp = trigger.newMap.get(empId);

boolean transition = trigger.IsInsert || (trigger.isUpdate && trigger.oldMap.get(emp.Id).Passed_Date__c != emp.Passed_Date__c);
if (emp.Passed_Date__c != null){
EmployeeToUpdate.Passed_Test_Account__c = EmployeeToUpdate.Active_Count__c.Passed_Test_Account__c + 1 ;
EmployeeToUpdate.add(EmployeeToUpdate);
}else if (emp.Passed_Date__c == 'null') {
EmployeeToUpdate.Active_Count__c = EmployeeToUpdate.Active + 0;
EmployeeToUpdate.add(Employee);
}
}
if(EmployeeToUpdate.Active_Count__c != null && !EmployeeToUpdate.Active_Count__c.isEmpty())
Database.update(EmployeeToUpdate.Active_Count__c);
}
}

 

 

 

Thank you!!

Hi Everyone,

As of right now I have a trigger that works exactly how I want it too but I am not able to get the test coverage working so that I can push it to production.  Can anyone help?  Below is the code for my trigger and my test coverage as it stands now...

 

Trigger

trigger AssignmentSubmitForApproval on lmscons__Transcript_Line__c (after update) {

for (Integer i = 0; i < Trigger.new.size(); i++) {

if (Trigger.old[i].lmscons__Percent_Complete__c == 0 && Trigger.new[i].lmscons__Percent_Complete__c == 100) {

// create the new approval request to submit
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setComments('Submitted for approval. Please approve.');
req.setObjectId(Trigger.new[i].Id);
// submit the approval request for processing
Approval.ProcessResult result = Approval.process(req);
// display if the reqeust was successful
System.debug('Submitted for approval successfully: '+result.isSuccess());
}
}
}

 

 

Test Coverage

@isTest
private class TestAssignmentSubmitForApproval {

static testMethod void MyUnitTest() {
lmscons__Transcript_Line__c lms = new lmscons__Transcript_Line__c();

lms.lmscons__Percent_Complete__c = 0;
//lms.lmscons__Transcript__c = lms.Id;
//lms.lmscons__Training_User_License__c = lms.id;

// insert the new lms
insert lms;
// change the probability of the lms so the trigger submits it for approval
lms.lmscons__Percent_Complete__c = 100;
// update the lms which should submit it for approval
update lms;
}
}

 

Note: the Transcript and User Liscensce fields are Master-Detail

 

Any help would be greatly appreciated!!

 

  • December 19, 2012
  • Like
  • 0

I am unable to create a new Force.com project

I enter my username/password  & security token but I keep getting the same error

 

I tried both Eclipse 3.5 & 3.4 same thing happens.

 

I tried a new security token - still unable to connect.

 

Can anyone please help.

 

This is from the log

 

WARN [2012-10-19 16:10:51,784] (BaseRetryAspect.java:isLoginExceptionRetryable:95) - Login evaluation deemed exception not retry-able:

SunCertPathBuilderException: unable to find valid certification path to requested target

WARN [2012-10-19 16:10:51,787] (BaseRetryAspect.java:isConnectionExceptionRetryable:131) - Connection evaluation deemed exception not retry-able:

SunCertPathBuilderException: unable to find valid certification path to requested target

WARN [2012-10-19 16:10:51,789] (ProjectController.java:getRemotePackageNames:882) - Unable to get project packages for project 'Mileage Tracker': unable to find valid certification path to requested target

WARN [2012-10-19 16:10:51,805] (ProjectOrganizationPage.java:prepareNextPage:271) - Unable to load org details - package names and component enablement

sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)

at java.security.cert.CertPathBuilder.build(Unknown Source)

at sun.security.validator.PKIXValidator.doBuild(Unknown Source)

at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)

at sun.security.validator.Validator.validate(Unknown Source)

at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(Unknown Source)

at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)

at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)

at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown Source)

at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)

at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)

at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)

at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)

  • October 19, 2012
  • Like
  • 0

Hi I want to place a custom Add to campaign button on a custom object list page similar to the standard add to campaign button on contact and lead list view.

 

So this is the standrad ADD TO Campaign Button URL on the  Contact List view page 

 

https://cs15.salesforce.com/ui/campaign/MassAddCMFromListingWizard?ent=contact&retURL=%2F003%3Ffcf%3D00B30000006tYyH&wizardRetUrl=%2F003%3Ffcf%3D00B30000006tYyH&macmflw_idSourceType=List&macmflw_memberType=Contact

 

https://cs15.salesforce.com/ui/campaign/MassAddCMFromListingWizard?ent=contact&retURL=%2F003%3Ffcf%3D00B30000006tYyH&wizardRetUrl=%2F003%3Ffcf%3D00B30000006tYyH&macmflw_idSourceType=List&macmflw_memberType=Contact

 

And using this i have wrote a custom Button 

 

https://cs15.salesforce.com/ui/campaign/MassAddCMFromListingWizard?ent=Relationship__c.id&retURL=%2Fa09%3Ffcf%3D00B30000006YRjw&wizardRetUrl=%2Fa09%3Ffcf%3D00B30000006YRjw&macmflw_idSourceType=List&macmflw_memberType=Lead

 

https://cs15.salesforce.com/ui/campaign/MassAddCMFromListingWizard?ent=Relationship__c.id&retURL=%2Fa09%3Ffcf%3D00B30000006YRjw&wizardRetUrl=%2Fa09%3Ffcf%3D00B30000006YRjw&macmflw_idSourceType=List&macmflw_memberType=Lead

 it almost same problem is in the standard contact list page i can select all the contacts and clicl add to campaigns and it takes to the right screen but where as with the custom button it takes to the add campaigns screen once we click the button but if i select some records on the custom object list page and then click on the Add to campaigns button i get an Error saying 

Unable to Access Page

The value of the "ids" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information.

 

 

Any Clue how to make this button work.

 

Thanks 

Akhil

  • October 19, 2012
  • Like
  • 0

Hello,

I am using Eclipse Galelio ver 3.5.2 and i am unable to login into the salesforce perspective with my credentials as it says connection timed out .also i have increased the time from 400 to 600 but still its not working .need help!!!

  • October 17, 2012
  • Like
  • 0