-
ChatterFeed
-
405Best Answers
-
0Likes Received
-
7Likes Given
-
1Questions
-
2506Replies
Issue with class and Visualforce page for custom object
public with sharing class Patient {
public String patientId{get;set;}
public Patient(){
String pat = apexpages.currentPage().getParameters().get('Id');
List<patient> patID = [Select id from Patient__c where id = :pat Limit 10];
}
}
Here is the visualforce page code:
<apex:page standardController="Patient">
<apex:detail />
</apex:page>
Can anyone tell me what I am doing wrong?
- Jeannine2017
- August 02, 2017
- Like
- 0
- Continue reading or reply
How to schedule a Schedulable class to run every hour?
Hi, I have the following schedulable class below and i wanted to be able to schedule it to run at 12am through the UI by navigating to schedule apex and then setting it to run every day at 12am. However, after this job has ran, i want it to schedule a subsequent job (same class) to run in the next hour. Is this possible?
The goal is to only schedule it through the UI to run at 12 Am and then it will automatically schedule the remaining jobs 1 hour later.
global class SampleClass implements Schedulable{ global void execute(SchedulableContext alistContext) { Database.executeBatch('myBatchClass', 100); //when database executebatch is done, I want to schedule the same job 1 hour later String cron_exp = '0 0 1 * * ?'; String jobName = 'somename'; System.Schedule(jobName, cron_exp, new SampleClass()) } }
- Raj R.
- July 26, 2017
- Like
- 0
- Continue reading or reply
I am getting error when trying to close popup window when clicks on save/cancel please help me
1. Only one account record is displaying in first page
2.Popup window is not closing after record update or cancel.
Below is my code:
Page1:
<apex:page standardController="Account" recordSetVar="accs">
<script>
function OpenVfpage(pid){
var newwindow = window.open('/apex/Accsmallpopup?id='+pid, 'name=_blank','height=500,width=500,left=250,top=100');
newwindow.focus();
}
</script>
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!accs}" var="a" >
<apex:column value="{!a.Id}"/>
<apex:column value="{!a.name}"/>
<apex:column value="{!a.Phone}"/>
<apex:column value="{!a.Industry}"/>
<apex:column id="two">
<apex:commandButton value="Click" onclick="OpenVfpage('{!a.id}')" reRender="two"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Page2:
<apex:page controller="Accpopup2" showHeader="false" sidebar="false" id="the">
<apex:form id="page">
<apex:pageblock id="close">
<apex:pageBlockSection >
<apex:inputfield value="{!a.Name}"/>
<apex:inputfield value="{!a.Phone}"/>
</apex:pageBlockSection>
<apex:pageblockbuttons >
<apex:commandButton value="save" action="{!save}"/>
<apex:commandButton value="cancel" action="{!cancel}"/>
</apex:pageblockbuttons>
<apex:inputHidden id="pass" value="{!status}"/>
</apex:pageblock>
<script language="JavaScript" type="text/javascript">
if(document.getElementById('the:page:close:pass').getAttribute('value') == 'true')
{
window.top.close();
}
</script>
</apex:form>
</apex:page>
Controller:
public class Accpopup2
{
public Account a {get;set;}
public string status {get;set;}
public Accpopup2()
{
a = new account();
}
public pagereference save()
{
ID caseID = apexpages.currentPage().getParameters().get('id');
if(caseid!=null)
{
account acc = [select Name,Phone from account where ID =: caseID];
acc.Name = a.Name;
acc.Phone = a.Phone;
update acc;
}
return null;
}
public pagereference cancel()
{
status = 'true';
return null;
}
}
- tulasiram ch
- July 26, 2017
- Like
- 0
- Continue reading or reply
Hi,I am new to salesforce. Wanted to know that, is there any functionality in SOQL that can work similar to "NVL" functionality in SQl?
- Vaishali mehta
- July 25, 2017
- Like
- 0
- Continue reading or reply
Best practice question: Parent update triggering update on children
- Michelle Grant
- March 22, 2017
- Like
- 0
- Continue reading or reply
Update a record through custom button - JS PROBLEM
When I click the Start button, i want status to change to 'In Progress'
I have used following JS code to achieve this
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var p = new sforce.SObject('Product_Order__c');
p.id = "{!Product_Order__c.Id}";
p.Status__c = "In Progress";
result = sforce.connection.update([p]);
location.reload(true);
But, in Apex Trigger, I want to do some complex stuff when status changes from Draft to In Progress.
In my afterUpdate event, I am hooking on
Product_Order__c newPO = (Product_Order__c)o;
Product_Order__c oldPO = (Product_Order__c)o;
system.debug(newPO.Status__c);
system.debug(oldPO.Status__c);
if (newPO.Status__c.equals('In Progress') && newPO.Status__c != oldPO.Status__c)
newInProgressPO.put (newPO.Id, newPO.RecordType.Name);
However, these two User Debugs show that both old and new statuses are 'In Progress' so my Map is always empty.
Does anybody have any ideas?
- Ivana Miserda
- March 22, 2017
- Like
- 1
- Continue reading or reply
When adding products to an Opportunity the list is not sorted alphabetically
This is my Apex code where it brings in the product list.
<apex:outputLabel value="Product Name" for="productName"/> <apex:selectList id="productName" value="{!PricebookEntrys}" size="1" required="true"> <apex:selectOptions value="{!items}"/> </apex:selectList>
Can anyone help sort the products alphabetically?
Thanks in advance for any assistance
- Matt Hewson
- March 17, 2017
- Like
- 0
- Continue reading or reply
SOQL query with map passed over to batch
Database.executeBatch(new JsonMassImportBatch('Select id, Name from Contract where id in : ' (Map in the batch class with the ids keyset should be here),'Contract',new JsonMassImportBatch.CustomObj(holdLease,new List<String>{'Current_Rental_Rate__c','Renewal_Date__c'},holdDate)));
The end is me passing in the map for the batch call to use ie holdlease
How should i format the batch side to make this work?
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query + LeaseMap.keySet());
}
- Tanner Russell
- March 10, 2017
- Like
- 0
- Continue reading or reply
Apex Error: List index out of bounds: 0
System.ListException: List index out of bounds: 0
This error occurs on lines 13, 34, 64, and 93. It looks like the list is pulling no records and I cannot figure out why. I have confirmed that all required fields are captured. I referenced another article that said to use @isTest (seeAllData=true) and it is still not working.
Help would be greatly appreciated - thank you in advance!!
@isTest (seeAllData=true)
private class leadsTaskHandlerTest {
@isTest static void testLeadsWorkflow() {
Lead newLead = new Lead(
Company = 'Test Account', FirstName= 'Test', LastName= 'Lead',
LeadSource = 'Web', Country = 'Canada', Email = 'something@gmail.com',
Status = 'Open', Lead_Type__c = 'New Car Franchise');
insert newLead;
Task[] tasks = [SELECT Id, Subject FROM Task WHERE WhoId = :newLead.Id AND Subject = 'Evaluate and Assign Web Lead'];
tasks[0].Status = 'Completed';
update tasks[0];
System.assert(taskCreatedForLead('Email Introduction of TradeRev to main contact person', newLead.Id));
System.assert(taskCreatedForLead('Phone call to follow up from email of introduction', newLead.Id));
System.assert(taskCreatedForLead('Schedule an appointment with lead; no voicemail if you don\'t connect', newLead.Id));
System.assert(taskCreatedForLead('Attempt to contact lead to set appointment second time in the week', newLead.Id));
System.assert(taskCreatedForLead('Any interest in TradeRev?; let\'s schedule a demo', newLead.Id));
System.assert(taskCreatedForLead('Touch base to let them know about growth/updates of TradeRev', newLead.Id));
System.assert(taskCreatedForLead('Are they ready to talk about TradeRev?', newLead.Id));
}
@isTest static void testContractWorkflow() {
Lead newLead = new Lead(
Company = 'Test Account', FirstName= 'Test', LastName= 'Lead',
LeadSource = 'Web', Country = 'Canada',
Status = 'Contract Given', Lead_Type__c = 'New Car Franchise');
insert newLead;
Task[] tasks = [SELECT Id, Subject FROM Task WHERE WhoId = :newLead.Id AND Subject = 'Any questions on the Registration Forms?'];
tasks[0].Status = 'Completed';
update tasks[0];
System.assert(taskCreatedForLead('Are the Registration Forms complete?', newLead.Id));
}
@isTest static void testDueDateEmail() {
Lead newLead = new Lead(
Company = 'Test Account', FirstName= 'Test', LastName= 'Lead',
LeadSource = 'Web', Country = 'Canada', Email = 'something@gmail.com',
Status = 'Contract Given', Lead_Type__c = 'New Car Franchise');
insert newLead;
Task newTask = new Task( Priority = 'Normal',
Status = 'Not Started',
ActivityDate = Date.today(),
WhoId = newLead.Id);
insert newTask;
update newTask;
}
@isTest static void testFranchiseDealerWorkflow() {
Account newAccount = new Account(
Name = 'Test Franchise Dealer',
AccountSource = 'Web',
Account_Type__c = 'New Car Franchise');
insert newAccount;
Task[] tasks = [SELECT Id, Subject FROM Task WHERE WhatId = :newAccount.Id AND Subject = 'Set appointment for Installation and Training Franchise'];
tasks[0].Status = 'Completed';
update tasks[0];
System.assert(taskCreatedForAccount('Assist with On-boarding', newAccount.Id));
System.assert(taskCreatedForAccount('Launch Cars; Walk back lot and try identify more cars they can load', newAccount.Id));
System.assert(taskCreatedForAccount('Has buyer been in touch to make arrangements for payment/pickup?', newAccount.Id));
System.assert(taskCreatedForAccount('Has buyer taken car? Mark car delivered', newAccount.Id));
System.assert(taskCreatedForAccount('Use TradeRev for the Live Appraisals', newAccount.Id));
System.assert(taskCreatedForAccount('Any other cars to launch?', newAccount.Id));
System.assert(taskCreatedForAccount('Reminder to buy cars on TradeRev', newAccount.Id));
System.assert(taskCreatedForAccount('Feedback on TradeRev; any referrals?', newAccount.Id));
System.assert(taskCreatedForAccount('Touch Point; How are you doing? Can I help with anything? Good time to sell cars on TradeRev', newAccount.Id));
//System.assert(taskCreatedForAccount('Monthly Report; Tips For Better Listings', newAccount.Id));
//System.assert(taskCreatedForAccount('Touch Point; How are you doing? Can I help with anything? Good time to sell cars on TradeRev', newAccount.Id));
//System.assert(taskCreatedForAccount('Monthly Report; Tips For Better Listings', newAccount.Id));
}
@isTest static void testIndepedentDealerWorkflow() {
Account newAccount = new Account(
Name = 'Test Independent Dealer',
AccountSource = 'Web',
Account_Type__c = 'Independent Dealer');
insert newAccount;
Task[] tasks = [SELECT Id, Subject FROM Task WHERE WhatId = :newAccount.Id AND Subject = 'Set appointment for Installation and Training'];
tasks[0].Status = 'Completed';
update tasks[0];
System.assert(taskCreatedForAccount('Assist with On-boarding', newAccount.Id));
System.assert(taskCreatedForAccount('Any questions on bidding?', newAccount.Id));
System.assert(taskCreatedForAccount('Have they been bidding? Any cars in pending?', newAccount.Id));
System.assert(taskCreatedForAccount('Won any cars? Discuss timing expectations for payment and pickup', newAccount.Id));
System.assert(taskCreatedForAccount('If a car has been won; have they paid and picked up car yet?', newAccount.Id));
System.assert(taskCreatedForAccount('Feedback on TradeRev; any referrals?', newAccount.Id));
System.assert(taskCreatedForAccount('Touch Point; How are you doing? Can I help with anything? Having success moving the cars bought on TradeRev?', newAccount.Id));
System.assert(taskCreatedForAccount('Touch Point; How are you doing? Can I help with anything? Having success moving the cars bought on TradeRev?', newAccount.Id));
}
static boolean taskCreatedForLead(String subject, Id id) {
Task[] tasks = [SELECT Id, Subject FROM Task WHERE WhoId = :id AND Subject = :subject];
if (tasks.size() > 0) {
tasks[0].Status = 'Completed';
update tasks[0];
return true;
}
else {
return false;
}
}
static boolean taskCreatedForAccount(String subject, Id id) {
Task[] tasks = [SELECT Id, Subject FROM Task WHERE WhatId = :id AND Subject = :subject];
if (tasks.size() > 0) {
tasks[0].Status = 'Completed';
update tasks[0];
return true;
}
else {
return false;
}
}
}
- DaNae Graham
- March 10, 2017
- Like
- 0
- Continue reading or reply
Code Not Covered by Test Class
I am using a test class for coverage 75% code, but few things are not covered. Can any one suggest what is going wrong.
this my test Class: --
@isTest public class TestProfessorSelectCourse { @isTest static void ProfessorCourse(){ Professor__c prof = new Professor__c(Name ='JP',Email__c='jp@gmail.com'); insert prof; Class__c cls = new Class__c(name='12G', Class_Teacher__c = prof.id); insert cls; Course__c cors = new Course__c(Professor__c=prof.id,Class__c =cls.id, name='Ruby', Start_Date__c= Date.today() , End_date__c= Date.newInstance(2017,03,20)); //Professor__c prof = new Professor__c(Name ='JP'); //cors.Professor__c = prof.Name; insert cors; } }
and below is my main class
Thanks
Mukesh
- mukesh gupta
- March 10, 2017
- Like
- 1
- Continue reading or reply
SObject row was retrieved via SOQL without querying the requested field: OpportunityLineItem.Opportunity
My extension:
public class PrintContract {
private final Opportunity opp;
public PrintContract(ApexPages.StandardController stdController) {
stdController.addFields(new String[]{
'Id',
'LinkContacttoOpportunity__c',
'Name',
'CloseDate',
'Contract__c',
'Type',
'Age__c',
'Amount',
'EXW_Expiration_Date__c',
'EXW_Effective_Date__c'
});
// get current opportunity record
this.opp = (Opportunity)stdController.getRecord();
}
public List<OpportunityLineItem> oli {get;set;}
public void olis(){
oli = new List<OpportunityLineItem>([SELECT Id, TotalPrice, Class__c, ServiceDate, OpportunityId, Quantity, Contract__c, Is_Accessory__c, Serial_Number__c
FROM OpportunityLineItem
WHERE OpportunityId = :opp.ID]);
}
}
My Page:
<apex:page standardController="Opportunity" extensions="PrintContract" action="{!olis}">
<apex:pageBlock rendered="{!Opportunity.HasOpportunityLineItem = TRUE}">
<apex:pageBlockTable value="{!oli}" var="ol">
<apex:column headerValue="Plan Number" value="{!ol.Contract__c}" />
<apex:column headerValue="Serial Number" value="{!ol.Serial_Number__c}" />
<apex:column headerValue="Purchase Date" value="{!ol.ServiceDate}" />
<apex:column headerValue="Plan Type" value="{!ol.Opportunity.Type}" />
<apex:column headerValue="Plan Effective Date" value="{!ol.Opportunity.EXW_Effective_Date__c}" />
<apex:column headerValue="Plan Expiration Date" value="{!ol.Opportunity.EXW_Expiration_Date__c}" />
<apex:column headerValue="Plan Cost" value="{!ol.TotalPrice}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
- Jean Grey 10
- March 08, 2017
- Like
- 0
- Continue reading or reply
Related List not showing up in roll-up object
- Steven Vawdrey 13
- March 07, 2017
- Like
- 0
- Continue reading or reply
Help with code coverage on trigger
I'm still pretty new to code development and I am using the following trigger and class.
Trigger:
trigger AccountTerritoryTag on Account (before insert, before update) { Set<String> setName = new Set<String>(); for (Account account : Trigger.new) { if (account.RunAssignment__c == TRUE) { setName.add(account.RoutingKey__c); } } if(setName.size() > 0 ) { List<RoutingKey__c> routingkey = [select Name,Territory__c from RoutingKey__c where Name in :setName ]; Map<String, RoutingKey__c> mapNameWiseR = new Map<String, RoutingKey__c> (); for(RoutingKey__c RK : routingkey ) { mapNameWiseR.put(RK.Name , RK); } for (Account account : Trigger.new) { if (account.RunAssignment__c == TRUE) { if (mapNameWiseR.containsKey(account.RoutingKey__c) ) { RoutingKey__c rk = mapNameWiseR.get(account.RoutingKey__c); //assign the territory account.Territory__c = rk.Territory__c; account.RunAssignment__c = FALSE; } } } } }
Test Class:
@isTest private class AccountTerritoryTest { static testMethod void AccountTerritoryTest() { Territory__c t = new Territory__c(); t.Name = 'TerritoryTest'; insert t; RoutingKey__c k = new RoutingKey__c(); k.Name = 'NAM|SMB|FL'; k.Territory__c = t.id; insert k; Account a = new Account(); a.Name = 'Test'; a.OverrideCountry__c = 'US'; a.OverrideEmployees__c = 'A) 1-100'; a.OverrideState__c = 'FL'; a.RunAssignment__c = TRUE; insert a; a.RunAssignment__c = FALSE; a.Territory__c = t.id; update a; } }
I'm stuck at 72% coverage and would like to increase as much as possible. I looked at my dev console and lines 17, 18, and 27-30 are uncovered by my class. I'm not certain how to write the class to cover these lines and the account update doesn't cover it. Can someone help/explain what I can do to fix this? Thank you in advance for the help!
- Will Bauzon
- March 07, 2017
- Like
- 0
- Continue reading or reply
Cannot deploy apex class with process builder in Salesforce
I believe the issue is because the process builder is inactive when it is deployed and the entire code is not covered as a result. How should I proceed with this?
I have already tried to do the following :
- Deploy the process builder first to activate it before deploying the classes. Deploying the process builder failed.
- Deploy the classes without the process builder; code coverage was 65%.
- Change the test class to accommodate more cases. This was not possible as I changed the code to work with process builder and I cannot find a way to test it.
- I ran the test code when the process builder was activated and deactivated. It showed 65% coverage when it was deactivated, and 100% coverage when it was activated, as the process builder is called when a record is inserted in the test class.
Public static void newRecord(List<Account> listAccounts) { for(Account a : listAccounts) { Account updacc=[select id from account where id = :a.id]; String message = String.valueof(a.get('Customer_Email__pc')); String hashDigest = CryptoUtil.generateHashDigest(message); updacc.Hashed_email__pc = HashDigest; update updacc; } }
I had to create a clone of the account record inserted/updated in order to use process builder. Using this method, the changes are only made in the clone. If process builder is not used, the test class gets a Null value instead of the actual hash value in the Hashed_email__pc field which leads to the test failing. When process builder is used, the changes made in the clone are reflected in the actual record, and the test passes. Even if I do not have a test method calling this section of code, the test passes as the process builder covers it.
I cannot figure out a way of creating a test class where the correct values are returned when the process builder is deactivated. I have to use DML to insert the record, so that it can be cloned.
How should I test the apex class in this case?
- Aishwarya MAHAJAN 8
- March 07, 2017
- Like
- 0
- Continue reading or reply
difference between created by and owner
What is the difference between Created by and Owner ?
- Ab
- April 13, 2016
- Like
- 0
- Continue reading or reply
Master-detail relationship field type not present for Account Object
Hi guyz,
In account object Master detail field is not available. Could you guyz tell me why is that? Thanks in advance
- Subhrajyoti Nath
- April 13, 2016
- Like
- 0
- Continue reading or reply
Number formating in VF
<td bgcolor="#BDD7E7"><strong>Close Date</strong></td> <td bgcolor="#C9D2E2">{!CO__c.Opportunity__r.CloseDate}</td>And it displays Tue Mar 02 00:00:00 GMT 2021
Can I make it display Mar 02 2021 ?
Similarly
<td bgcolor="#BDD7E7"><strong> Value</strong></td> <td colspan="3" bgcolor="#C9D2E2">${!(ROUND(CO__c.Opportunity__r.Amount,0))}</td>displays $4502
Can I make it display $4,502 ?
(Add "," every 3 digits, no decimal)
Thanks!
- Andyux
- April 11, 2016
- Like
- 0
- Continue reading or reply
Help!! "Apexpages.addMessage" Not Displaying On VisualForce Page With Search Field
I am very new to VisualForce and Apex and would appreciate some help. I know I am miissing something out but can't seem to figure it out.
Apex Class:
public class QFSearchController { String searchText; List<Quality_Feedback__c> results; public String getSearchText() { return searchText; } public void setSearchText(String s) { searchText = s; } public List<Quality_Feedback__c> getResults() { return results; } public PageReference doSearch() { if(searchText==null || searchText=='') { Apexpages.addMessage(new Apexpages.Message(ApexPages.severity.INFO, 'Search term must be longer than one character:')); } else if (searchText.length()<2) { Apexpages.addMessage(new Apexpages.Message(ApexPages.severity.INFO, 'Input box must contain at least two characters')); } results = (List<Quality_Feedback__c>)[FIND :searchText RETURNING Quality_Feedback__c(Name, Type_of_Feedback__c, Feedback_For__c, Reviewed_By__c, Review_Status__c, Incident__c)][0]; return null; } }
VisualForce Page:
<apex:page controller="QFSearchController"> <apex:ListViews type="Quality_Feedback__c" /> <apex:form > <apex:pageBlock mode="edit" id="block"> <apex:pageBlockSection > <apex:pageBlockSectionItem > <apex:outputLabel for="searchText">Search Text</apex:outputLabel> <apex:panelGroup > <apex:inputText id="searchText" value="{!searchText}"/> <apex:commandButton value="Go!" action="{!doSearch}" rerender="block" status="status"/> </apex:panelGroup> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:actionStatus id="status" startText="requesting..."/> <apex:pageBlockSection title="Results" id="results" columns="1"> <apex:pageBlockTable value="{!results}" var="l" rendered="{!NOT(ISNULL(results))}"> <apex:column value="{!l.name}"/> <apex:column value="{!l.Type_of_Feedback__c}"/> <apex:column value="{!l.Feedback_For__c}"/> <apex:column value="{!l.Reviewed_By__c}"/> <apex:column value="{!l.Review_Status__c}"/> <apex:column value="{!l.Incident__c}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> <apex:pageMessages /> </apex:form> </apex:page>
Thanks in advance.
- Fitzgerald Anukam
- April 10, 2016
- Like
- 0
- Continue reading or reply
image picklist formula returns value, not image
"<img src="/servlet/servlet.FileDownload?file=0151600000QNE8V" alt=" " border="0"/>"
Instead of the image. Seems like a need URL reference?
This is the code on VF page to display picklist
<apex:outputField value="{!customo__c.Flag__c}" > <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> </apex:outputField>and field Flag__c is picklist "Green" , "Red"
This is the code on VF page to display image
{!customo__c.Flag_formula__c}This is the fromula (text) for field "Flag_formula__c"
IMAGE( CASE(Flag__c, "Green","/servlet/servlet.FileDownload?file=0151600000QNE8V", "Red","/servlet/servlet.FileDownload?file=0151600000QNE8f", ""),"")The images URL work
https://c.na23.content.force.com/servlet/servlet.FileDownload?file=0151600000QNE8V
https://c.na23.content.force.com/servlet/servlet.FileDownload?file=0151600000QNE8f
- Andyux
- April 09, 2016
- Like
- 0
- Continue reading or reply
How can i hide the Stage field in the opportunities object which is a required standard field.
Can anyone help me how to hide the stage filed in the opportunites object which is a required standard field.
Thanks in advance.
Virinchi.
- Virinchi Bairisetty
- April 08, 2016
- Like
- 0
- Continue reading or reply
History Tracking on User Object
I need to fetch history of user record in Apex Class. Is there any way to enable history tracking on User Obejct. I do not see "Set History Tracking" button above User Fields like we see in Account object.
- Shashikant Sharma
- June 09, 2011
- Like
- 0
- Continue reading or reply
No such column 'QuantityUnitOfMeasure' on entity 'Product2'
But in Product entity field seems there.
Not sure if I am using a wrong field name. In docs I couldn't find this field though. Can someone help me with reading unit of measure in product using SOQL?
Appreciate any help. Thanks.
- Pasan Eeriyagama
- August 03, 2017
- Like
- 0
- Continue reading or reply
Issue with class and Visualforce page for custom object
public with sharing class Patient {
public String patientId{get;set;}
public Patient(){
String pat = apexpages.currentPage().getParameters().get('Id');
List<patient> patID = [Select id from Patient__c where id = :pat Limit 10];
}
}
Here is the visualforce page code:
<apex:page standardController="Patient">
<apex:detail />
</apex:page>
Can anyone tell me what I am doing wrong?
- Jeannine2017
- August 02, 2017
- Like
- 0
- Continue reading or reply
Excel to Salesforce
User attaches an excel doc to a case record. The values in the excel doc will populate specific case fields. (The column headers will match the case fields). Salesforce Classic, not lightning.
Thanks for any advice on best way to handle!
- Peter Reid 12
- August 01, 2017
- Like
- 0
- Continue reading or reply
I have my UI on salesforce. I want a piece of code to execute on some server. How this can be achieved?
- Vaishali mehta
- August 01, 2017
- Like
- 0
- Continue reading or reply
How can I populate a master-detail field ?
Could you help? I created a field related to the account object and I want to fill in autometico when creating a record by Dataloader, the CSV file only contains the customer number, but not the account name (Account)
I have tried to populate that field by Process Builder, but I do not start as, the other option is to do a trigger, which as soon as the CSV is loaded, it will be triggered and compare "Customer Number" of my custom object against "Client Number" (Accounts) and if it is the same, fill in the field Master-detail, in my custom object. Do you have any idea how to do this trigger?
Look out for comments.
- Juan Rafael Motta Velasco 4
- July 28, 2017
- Like
- 0
- Continue reading or reply
Validation rule triggered in error on insert from another object
The issue arises when a record in the object is created from another custom object in the managed package. We are using Process Builder to populate the field that the validation rule is on with the text from a custom field in the originating object. It worked flawlessly until I created the validation rule. The text field in the originating object is only 30 characters long so it cannot exceed the rule limits. With the validation rule activated every time the originating object inserts a record the validation rule causes an error and prevents the insertion. And the Validation Rule fires before the Process Builder does so it cannot be the text length in the originating field causing the error.
Any ideas??
- Dave Wolfe 11
- July 27, 2017
- Like
- 0
- Continue reading or reply
edit the edit button
- Lindsey Palmquist
- July 27, 2017
- Like
- 0
- Continue reading or reply
How to schedule a Schedulable class to run every hour?
Hi, I have the following schedulable class below and i wanted to be able to schedule it to run at 12am through the UI by navigating to schedule apex and then setting it to run every day at 12am. However, after this job has ran, i want it to schedule a subsequent job (same class) to run in the next hour. Is this possible?
The goal is to only schedule it through the UI to run at 12 Am and then it will automatically schedule the remaining jobs 1 hour later.
global class SampleClass implements Schedulable{ global void execute(SchedulableContext alistContext) { Database.executeBatch('myBatchClass', 100); //when database executebatch is done, I want to schedule the same job 1 hour later String cron_exp = '0 0 1 * * ?'; String jobName = 'somename'; System.Schedule(jobName, cron_exp, new SampleClass()) } }
- Raj R.
- July 26, 2017
- Like
- 0
- Continue reading or reply
I am getting error when trying to close popup window when clicks on save/cancel please help me
1. Only one account record is displaying in first page
2.Popup window is not closing after record update or cancel.
Below is my code:
Page1:
<apex:page standardController="Account" recordSetVar="accs">
<script>
function OpenVfpage(pid){
var newwindow = window.open('/apex/Accsmallpopup?id='+pid, 'name=_blank','height=500,width=500,left=250,top=100');
newwindow.focus();
}
</script>
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!accs}" var="a" >
<apex:column value="{!a.Id}"/>
<apex:column value="{!a.name}"/>
<apex:column value="{!a.Phone}"/>
<apex:column value="{!a.Industry}"/>
<apex:column id="two">
<apex:commandButton value="Click" onclick="OpenVfpage('{!a.id}')" reRender="two"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Page2:
<apex:page controller="Accpopup2" showHeader="false" sidebar="false" id="the">
<apex:form id="page">
<apex:pageblock id="close">
<apex:pageBlockSection >
<apex:inputfield value="{!a.Name}"/>
<apex:inputfield value="{!a.Phone}"/>
</apex:pageBlockSection>
<apex:pageblockbuttons >
<apex:commandButton value="save" action="{!save}"/>
<apex:commandButton value="cancel" action="{!cancel}"/>
</apex:pageblockbuttons>
<apex:inputHidden id="pass" value="{!status}"/>
</apex:pageblock>
<script language="JavaScript" type="text/javascript">
if(document.getElementById('the:page:close:pass').getAttribute('value') == 'true')
{
window.top.close();
}
</script>
</apex:form>
</apex:page>
Controller:
public class Accpopup2
{
public Account a {get;set;}
public string status {get;set;}
public Accpopup2()
{
a = new account();
}
public pagereference save()
{
ID caseID = apexpages.currentPage().getParameters().get('id');
if(caseid!=null)
{
account acc = [select Name,Phone from account where ID =: caseID];
acc.Name = a.Name;
acc.Phone = a.Phone;
update acc;
}
return null;
}
public pagereference cancel()
{
status = 'true';
return null;
}
}
- tulasiram ch
- July 26, 2017
- Like
- 0
- Continue reading or reply
How do I get a Sales Process selected stage values using SOQL
My thoughts were that this information would be stored in a Picklist, but I have only been able to get to the various Sales Process values:
Find the FieldDefinitionId
SELECT EntityDefinitionId, QualifiedAPIName, FieldDefinitionId FROM EntityParticle WHERE EntityDefinition.QualifiedApiName LIKE '%Business%' AND DataType = 'picklist'
Get the Picklist values based on the EntityParticleId which will equal the FieldDefinitionId
SELECT DurableId,EntityParticleId,Id,IsActive,IsDefaultValue,Label,ValidFor,Value FROM PicklistValueInfo WHERE EntityParticleId = 'BusinessProcess.TableEnumOrId' ORDER BY label
How do you get those Selected Values ... if it can be done on the Sales Process page you would think you'd be able to use SOQL to get that information.
Thank you in advance for your time and input.
- Sell-On Dev
- July 26, 2017
- Like
- 0
- Continue reading or reply
Hi,I am new to salesforce. Wanted to know that, is there any functionality in SOQL that can work similar to "NVL" functionality in SQl?
- Vaishali mehta
- July 25, 2017
- Like
- 0
- Continue reading or reply
Dynamic Label and Checkboxes underneath?
I'm working with a visualforce page and form and I wanted to display a list if U.S. States as just text with checkboxes underneath each state for the cities in that state.
So for example:
Nevada
- Reno
- Carson City
- Las Vegas
Colorado
- Denver
- Boulder
I have a custom object that stores customer records. In the address fields I store the city and state. I want to generate the output above using this data and have a checkbox rendered for each city.
Any ideas on how to do this using visualforce?
- West415
- September 16, 2015
- Like
- 1
- Continue reading or reply
Enhanced List VisualForce Page
<apex:page sidebar="false" > <apex:enhancedlist type="Location__c" height="730" customizable="false" rowsPerPage="50" Listid="00B19000000S8a3" /> </apex:page>
- Sandra O
- September 04, 2015
- Like
- 1
- Continue reading or reply
When we click on button in one org it will automatically create contact in another org by using Soap API Callout
I have written one class in org1.I generated wsdl file and partner wsdl of that class. I login to other salesforce org2 and import those two files into this org. I created one stub class in org2 and using this class i have called those classes and methods and callout this stub class using developer console. While executing this class it throws an error [System.CalloutException: IO Exception: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = https://login.salesforce.com/services/Soap/u/34.0]. I have pasted login url in Remote site settings in org 2.
Apex class in Org1:
global class webservicesoap1
{
webservice static string createcontact(string Fname,string Lname,String phone)
{
list<contact> conlist=[select id from contact where firstname =:fname and lastname =:lname and phone =:phone];
if(conlist.size()!=0)
{
return 'contact already exists';
}
else{
contact c=new contact();
c.firstname=fname;
c.lastname=lname;
c.phone=phone;
insert c;
return c.id;
}
}
}
Stub Class i implemented in org2:
public class soapcallout
{
public soapcallout(ApexPages.StandardController controller) {
}
public soapcallout()
{
partnerSoapSforceCom.soap spc=new partnerSoapSforceCom.soap();
string username ='sfgt@283.com';
string password ='radhekrishna***AIyGjqKUpuRnKaBzoX6XRUnzH';
partnerSoapSforceCom.loginresult loginresult = spc.login(username, password);
system.debug(loginresult.sessionid);
soapSforceComSchemasClassWebservice.webservicesoap1 websrvc= new soapSforceComSchemasClassWebservice.webservicesoap1();
soapSforceComSchemasClassWebservice.SessionHeader_element sessionheader =new soapSforceComSchemasClassWebservice.SessionHeader_element();
sessionheader.sessionid = loginresult.sessionid;
websrvc.timeout_x = 120000;
websrvc.sessionheader = sessionheader;
string s = websrvc.createcontact('Mahesh','Krishna','9526389523');
}
}
- Salesforce 283
- June 26, 2015
- Like
- 1
- Continue reading or reply
i want to update a lookup field in opportunity
when i convert lead to opportunity i want to display lead name that converted in opportunity.i want to write it in triggers based on a check box i am updating that field.
- ravi teja 81
- April 24, 2015
- Like
- 1
- Continue reading or reply
Is anyone using Cloud9 to build on Force.com?
Cloud9 looks like the perfect solution for salesforce developers. The two cloud geeks are already working together with Heroku so why don't they have a OOTB Cloud9 solution for Salesforce.com development?
Has anyone tried to hook up a salesforce org with Cloud9? If not someone should make that happen. Or maybe I should have a go at it.
I looked at BrainEngine but the sign up page gives an azure 403, for that last week. It didn’t look like BrainEngine had more than one guy supporting it, and not open source. Maybe I’m overlooking something?
Any up dates on whats going on would be helpful.
- Tim Mays
- February 12, 2015
- Like
- 1
- Continue reading or reply
Uncaught ReferenceError: Ext is not defined
- Ravikant kedia
- November 15, 2014
- Like
- 2
- Continue reading or reply
Why you might get OP_WITH_INVALID_USER_TYPE_EXCEPTION from a trigger
Posting this in order to help others who, months from now, might Google "OP_WITH_INVALID_USER_TYPE_EXCEPTION" and find this explanation.
We wrote an Apex trigger on the User object, to insert a custom object record anytime a user updates their Chatter status. This was done to fulfill a client's requirement to audit all Chatter activity.
The trigger worked fine, until one day the client signed up some Chatter Free users. When such a user tried to update their status, they got a pop-up with an OP_WITH_INVALID_USER_TYPE_EXCEPTION error.
We scratched our collective heads for awhile. After all, Apex triggers run in "system mode," right? That is supposed to mean that "object and field-level permissions of the current user are ignored." And yet this trigger seemed like it was running in "user mode," enforcing restrictions based on who the current user was.
The root cause turned out to be that a Chatter Free user cannot be the owner of a custom object record, and SFDC by default sets the current user as a new record's first owner. We discovered this when we realized, via experiment, that Apex triggers fired as the result of actions by Chatter Free users could definitely update an existing record, but were having problems creating records.
So the simple solution was to explicitly set the owner of the new record to some fully-licensed user prior to inserting it.
- Glenn Weinstein
- April 05, 2012
- Like
- 36
- Continue reading or reply