- Vinnie B
- NEWBIE
- 70 Points
- Member since 2013
- Salesforce Specialist
- Save The Bay
-
ChatterFeed
-
1Best Answers
-
0Likes Received
-
0Likes Given
-
25Questions
-
60Replies
Is there a way to view all of the assignments for a given object?
Also, seeing this I decided to be very careful when creating new objects to assign them properly then. But it appears that you're not given the option to set permissions at the time of creation for a new object.
Is this a recent change? I don't remember it being this tedious to assign object permissions to many profiles.
- Vinnie B
- May 19, 2015
- Like
- 0
- Continue reading or reply
Is there a way to get rid of the Action column in a related list?
- Vinnie B
- May 19, 2015
- Like
- 0
- Continue reading or reply
How to create a simple VF page that redirects immediately to a new URL
I'm simply trying to override the New button on a custom object to a URL which pre-populates the Name field. The URL was easy to develop (below). It works just like the standard New button but one field is populated with some text. (We use a workflow rule to set the Name field so there's no need for the user to enter anything.)
https://na18.salesforce.com/a0o/e?Name=[Set%20by%20Workflow%20Rule]&retURL=%2Fa0o%2Fo
When I want to change the default button it asks me for a VF page. I have tried creating a simple VF page that just redirects to the URL above. I'm a pretty novice VF developer and this simple task has got me struggling.
Thanks!!
- Vinnie B
- May 19, 2015
- Like
- 0
- Continue reading or reply
Why does a Scheduled Job automatically become a Queued job?
How can I code my scheduled job so that it doesn't permanently take up a queued job? I find it odd that a monthly process should count for one fifth of my limit in this regard.
Note that my Apex code is running fine.
Thanks!
- Vinnie B
- April 28, 2015
- Like
- 0
- Continue reading or reply
Generic data integration question - taking .csv data from an external source and importing into SFDC
I'm thinking the best approach is to develop an Apex class that runs as a daily scheduled job. The Apex class will do an HTTP request to get the files from the external location, process the data as needed in the Apex code, and populate the appropriate fields.
I've done a fair amount of Apex coding and think I can do this. My question is regarding the general strategy of this. Is there a better way to do this? Are there any gotchas that I need to worry about in doing it this way?
Thanks!!
- Vinnie B
- November 26, 2014
- Like
- 0
- Continue reading or reply
Metadata downloads workflow files but not contact.workflow
I looked through the logs and saw some Java exceptions at the time of a metadata refresh but they didn't give me a clue as to why this would be happening. Does anybody have any clues as to why some metadata components would be downloaded while others aren't being downloaded?
Thanks!!
- Vinnie B
- November 18, 2014
- Like
- 0
- Continue reading or reply
One more question about adding complex CSS/JS into a VF page - What does "::after" mean?
One thing I've noticed is that the rendered HTML shows the "::after" code where I'm having problems. I Googled on this but couldn't find much of an explanation, even as to how this is used in standard HTML/CSS. Any ideas on what causes this and how to get around it would be greatly appreciated.
THANKS!!
- Vinnie B
- September 08, 2014
- Like
- 0
- Continue reading or reply
OutputLink, and other HTML, getting rendered with escaped characters
I'm trying to set a simple HTML link in a VF page. I'm using code like:
<apex:outputLink value="http://www.cnn.com"> here</apex:outputLink>Looking at the HTML source of the rendered page I see:
<apex:outputLink value="https://www.cnn.com"> here</apex:outputLink>.This shows the 'here' with the appropriate link, but the URL is also showing to the user after that.
First, why are the lesser and greater signs escaped? Secondly, I'm assuming there's got to be a way to include a simple link that doesn't show the URL itself.
Again, I'm pretty good with Apex but just getting into VF. This is likely some basic concept of VF that I'm missing.
Thanks!!
- Vinnie B
- September 08, 2014
- Like
- 0
- Continue reading or reply
How can you prevent future functions from locking out other future functions?
Occassionally, I'll get a message about locked rows. This is, of course, quite bad as some of my updates just don't happen.
I did some other coding with batch files and got around this by having Batch-1 call Batch-2 which calls Batch-3, etc. Is there some way to make sure five different future calls won't run at the same time?
Thanks!
- Vinnie B
- July 31, 2014
- Like
- 0
- Continue reading or reply
Changes in test class processing with Summer '14 release?
I checked and the test code on production hasn't been changed since February but just started failing this week.
Any ideas? Thanks!!
- Vinnie B
- July 16, 2014
- Like
- 0
- Continue reading or reply
Easy way to take an List with duplicates to one without?
I've settled on this code which is pretty concise but is a shotgun approach. I'm thinking there has to be an easier way (using Maps?). Any comments?
Thanks!!
for (Opportunity anOpp1 : FullListOfOpps) {
FOUND = false; // boolean
for (Opportunity anOpp2 : ListOfOppsWithoutDuplicates) {
if (anOpp2.Id == anOpp1.Id) {
FOUND = true;
}
}
if (!FOUND) {
Opportunity newOpp = new Opportunity();
newOpp.id = anOpp1.id;
ListOfOppsWithoutDuplicates.add(newOpp);
}
}
- Vinnie B
- June 26, 2014
- Like
- 0
- Continue reading or reply
Eclipse giving "Save failed!" and "Nothing to save to project - retrieve result is empty" upon saving
I initially thought this was due to code as I could remove all of my code and get the file to save. However, when I then started putting code back in to see what me be causing the problem, the results were not consistent. I can understand if I made coding errors. I do that all the time. :) But I wasn't getting any of the typical messages that the compiler or Salesforce gives me when I make these errors.
Has anyone seen this before? I'm planning on trying this against a new sandbox to see if that's the issue. After that I'll assume it's the Eclipse binaries somehow being corrupted and will try the latest version.
---
!ENTRY com.salesforce.ide.core 2 0 2014-06-11 16:03:28.500
!MESSAGE WARN [2014-06-11 16:03:28,499] (ProjectService.java:handleDeployResult:1909) - Save failed!
!ENTRY com.salesforce.ide.core 2 0 2014-06-11 16:03:28.504
!MESSAGE WARN [2014-06-11 16:03:28,501] (ProjectService.java:handleRetrieveResult:2085) - Nothing to save to project - retrieve result is empty
- Vinnie B
- June 11, 2014
- Like
- 0
- Continue reading or reply
Can't get two tabs in a tabPanel to display correctly
Tabs
VF page with table
And this when Tab 2 is selected.
Tabs - VF page with table.
Obviously, I don't want the tabs on top of my VF page, not pushing it off to the right.
The tab panel code is pretty simple:
<apex:page showHeader="true">
<style>
.activeTab {background-color:#236FBD; color:white; background-image:none}
.inactiveTab {background-color:lightgrey; color:black; background-image:none}
</style>
<apex:tabPanel switchType="client" selectedTab="tab1" id="ODTabPanel"
activeTabClass="activeTab" tabClass="activeTab" inactiveTabClass="inactiveTab">
<apex:tab label="Program - 1" name="Program1" id="tab2">
<apex:include pageName="OD_Display_Program2"/>
</apex:tab>
<apex:tab label="Program - 2" name="Program2" id="tab1">
<apex:include pageName="OD_Display_Program1"/>
</apex:tab>
</apex:tabPanel>
</apex:page>
The code for the VF pages called by the tabPanel is also pretty simple:
<apex:page controller="OD_Display_Program1Controller" showHeader="TRUE" standardStylesheets="TRUE" cache="FALSE">
<apex:outputPanel >
<table width="100%" border="1" cellpadding="5%" bgcolor="CCEEEE">
... lots of stuff in the table
</table>
</apex:outputPanel>
</apex:page>
The other tab is basically the same. It just grabs different data. I did flip the two around and the problem remains with the VF page called by the second tab.
Any ideas as to why the page won't display correctly? Thanks!!
- Vinnie B
- March 13, 2014
- Like
- 0
- Continue reading or reply
Trying to trigger iContact Send functionality programmatically
- Create an iContact campaign
- Query for a given set of contacts
- Add these contacts to the iContact campaign
- Send the email using iContact
Has anyone sent off iContact emails programmatically? If so, any help you could provide would be greatly appreciated.
- Vinnie B
- February 27, 2014
- Like
- 0
- Continue reading or reply
Getting "Too many DML rows: 10001" but I only have 5,000 rows to insert
counter ++;
STB_Constituent__c stbc = new STB_Constituent__c();
stbc.Contact_ID__c = (String) cID;
constituents.add(stbc);
if (counter == 5000) {
try {
insert constituents;
counter = 0;
constituents.clear();
} catch (System.DmlException dmlEx) {
throw dmlEx;
}
This code seems to be working well, but I'm still getting the error message. Note that in my logs below it says it's only going to insert 5,000 records but then the next line says that's over 10,000. Am I missing something as to what constitutes a "DML row". I'll try again using a batch size of 1,000 and see how that goes.
11:27:54.704 (31704666000)|DML_BEGIN|[94]|Op:Insert|Type:STB_Constituent__c|Rows:5000
11:27:54.704 (31704687000)|EXCEPTION_THROWN|[94]|System.LimitException: Too many DML rows: 10001
11:27:54.704 (31704768000)|HEAP_ALLOCATE|[94]|Bytes:28
11:27:54.706 (31706178000)|FATAL_ERROR|System.LimitException: Too many DML rows: 10001
- Vinnie B
- January 27, 2014
- Like
- 0
- Continue reading or reply
Variables always reset in the execute function of a Batch Apex class
I have a feeling that the issue of this being a variable in a global class is causing the problem. Does that make sense? If so, is there a way around this?
Thanks!!
---
global class OrgDashboardBatchable implements Database.Batchable<SObject> {
global String glstrQuery;
global List<SObject> gllstScopeRecords;
private Integer numberOfContacts = 0;
private ID theODB_ID;
global OrgDashboardBatchable(ID odbID) {
glstrQuery = 'SELECT Id FROM Contact WHERE cv__Active__c = TRUE';
theODB_ID = odbID;
}
global Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator(glstrQuery);
}
global void execute(Database.BatchableContext bc, List<SObject> lstBatchRecords) {
// The first debug message is always zero. The second does show the size of this batch.
gllstScopeRecords = lstBatchRecords;
System.debug('In execute: numberOfContacts1 = ' + numberOfContacts);
numberOfContacts += gllstScopeRecords.size();
System.debug('In execute: numberOfContacts2 = ' + numberOfContacts);
}
global void finish(Database.BatchableContext bc) {
// Code that works correctly
}
}
- Vinnie B
- January 15, 2014
- Like
- 0
- Continue reading or reply
Best way to get around the 50000 query row error message?
I can run this query easily in the Developer Console to get my results even if well over 50K. I looked into dividing the query up into different segments (i.e. by CreatedDate) and using a Batchable class. Both of these seemed like a fair amount of effort to simply run a query. I figured I'd ask here to see if there's a better way to do this.
I do plan on putting this into a scheduleable job that will run at 3:00 am or so. Running the code manually in production is causing the problem. I'm not sure if the scheduleable aspect alone will make a difference.
Thanks!!
- Vinnie B
- January 14, 2014
- Like
- 0
- Continue reading or reply
Which is the Best Database Tool for SF?
I saw a similar post on this from 2009 but I'm assuming that's ancient history as far as SFDC is concerned.
I've been using the Query Editor within the Developer Console but have some issues with that:
1) There is no ability to export data to a spreadsheet.
2) It appears that when I use this in a sandbox I don't see the results of joins into parent object. I do see these results when I'm on our Production system.
I also tried the Force.com Explorer tool but I have problems with this as well.
1) While this works ok as a Data Dictionary, I can't see the type of a given field. They present all sorts of information I'm not familiar with about the field (i.e. groupable, namePointing), but don't even tell me the field type!
2) I also don't see the results of parent fields when doing simple queries.
I know that running raw queries isn't they way they want you to use Salesforce, but it's often necessary when debugging complex reporting tasks or testing out code development. Any help on this would be greatly appreciated.
- Vinnie B
- December 11, 2013
- Like
- 0
- Continue reading or reply
Trying to do a simple join on a custom object
I can run the following simple query on the standard Account and Contacts object to include values from the parent object when querying the child object.
select firstName, lastName, Account.Name
from Contact
where firstName like 'Vinn%'
However, when I try to do this on a custom object I created, Custom_Account__c, I can't get it to work at all. I set up the lookup field on Contact to have the same relationship as it does with the regular Account object (parent/child).
I tried the following query and many other permutations including putting the relationship name (Contacts) in place of Custom_Account__c, doing this with and without "__r" appended to it.
select firstName, lastName, Custom_Account__c.Number_Field__c
from Contact
where firstName like 'Vinn%'
I tried all sorts of variations but I keep getting the error:
"Didn't understand relationship 'Custom_Account__c' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names."
I don't understand why I can't simply reference the fields in a custom parent object as I do with a standard parent object.
Thanks!
- Vinnie B
- December 11, 2013
- Like
- 0
- Continue reading or reply
Would like to put an 'Add Attachment' button onto a VF page on the contact page layout
We're trying to get rid of the Notes and Attachments section of the Contact page layout since it's not customizable. However, we need a new "Attachments" section to replicate the attachments functionality of that related list.
I figured out how to create a VF page which shows the Attachments for the contact and have put that on the page layout. I am stuck at adding an "Add Attachment" button on this page.
I think it's down to just writing a controller that will open the standard add attachment page and linking that attachment to the contact. Any help here would be appreciated.
Note that I'm not trying to do anything with the file contents. I just want the standard Add Attachment functionality that you see in the default Notes and Attachments related list.
I'm fairly new to VF so this is hopefully something that's pretty simple. :)
THANKS!!
- Vinnie B
- November 06, 2013
- Like
- 0
- Continue reading or reply
How to create a simple VF page that redirects immediately to a new URL
I'm simply trying to override the New button on a custom object to a URL which pre-populates the Name field. The URL was easy to develop (below). It works just like the standard New button but one field is populated with some text. (We use a workflow rule to set the Name field so there's no need for the user to enter anything.)
https://na18.salesforce.com/a0o/e?Name=[Set%20by%20Workflow%20Rule]&retURL=%2Fa0o%2Fo
When I want to change the default button it asks me for a VF page. I have tried creating a simple VF page that just redirects to the URL above. I'm a pretty novice VF developer and this simple task has got me struggling.
Thanks!!
- Vinnie B
- May 19, 2015
- Like
- 0
- Continue reading or reply
Test Class for Schedule class
// // AutoCaseCreate.cls --- can be scheduled to run at any time interval // global class AutoCaseCreate implements Schedulable { // Callable from a Unit Test public void execute() { // Find the Contacts with Related Sales Tax orgs, // so that we can assign a new Case to it list<Group> USTRID = [SELECT Email,Id,Name,Type FROM Group WHERE Type =:'queue' AND Name=:'USTR' limit 1]; for(contact con : [SELECT Id, (SELECT Id, Name FROM Sales_Tax_Orgs__r ) FROM Contact WHERE Id IN (SELECT Contact__c from Sales_Tax_Org__c WHERE Name != '')]) { // Create a new Case for every contact related to sales tax orgs Case c = new Case( Priority = 'Medium', Status = 'New', Subject = 'USTR: Initial EOM Request', OwnerId = USTRID[0].id, Category__c = 'Accounting', Sub_Category__c = 'University Sales Tax Reporting', Origin = 'YSS USTR Initiated', ContactId = con.id ); // Try to insert our Case try { insert c; } catch (DMLException ex) { // Handle the error } } } global void execute(SchedulableContext sc) { execute(); } }Here is my code for a schedule class. I'm not an expert in coding and i'have written this code with the help of some existing forums. It would be very helpful if you guys suggest me how to write the test class for this.
Thanks
- Narsimha Rao
- April 29, 2015
- Like
- 0
- Continue reading or reply
help with Test Class
trigger UpdateCR on Case (before update) { Map<String, Schema.RecordTypeInfo > caseRecordTypes = Case.sObjectType.getDescribe().getRecordTypeInfosByName(); Id recordTypeId = caseRecordTypes.get('US Cases Locked RT').getRecordTypeId(); for ( Case c : Trigger.new) { if (c.CF_Tracking__c != null ){ if( c.Status == 'Closed') { c.RecordTypeId = recordTypeId; } } } }
- Javagal
- April 28, 2015
- Like
- 0
- Continue reading or reply
System.Limit Exception: Too many SOQL queries: 101
It is called by the following trigger:
trigger triggerUpdateTravelChange on Travel_Detail__c (after update, before update) {
Travel_Detail__c[] travel_details = Trigger.new;
If(Trigger.Isafter){
//Updates the Change Travel Ticket Date and
//Increments the Change Travel Ticket Revision
//on the Travel Ticket
UpdateTravelChange.findTravelDetail(travel_details);
updateTravelDetailStatus.updateTravelTicket(travel_details);
//TravelCalendarUpdate.TravelDetail(travel_details);
}
If(Trigger.Isbefore){
//Updates the Change Revision and Change Date Fields
// on the Travel Detail Record
TravelDetailBooked.updateBooked(travel_details);
}
}
Apex Class
trigger triggerUpdateTravelChange on Travel_Detail__c (after update, before update) {
Travel_Detail__c[] travel_details = Trigger.new;
If(Trigger.Isafter){
//Updates the Change Travel Ticket Date and
//Increments the Change Travel Ticket Revision
//on the Travel Ticket
UpdateTravelChange.findTravelDetail(travel_details);
updateTravelDetailStatus.updateTravelTicket(travel_details);
//TravelCalendarUpdate.TravelDetail(travel_details);
}
If(Trigger.Isbefore){
//Updates the Change Revision and Change Date Fields
// on the Travel Detail Record
TravelDetailBooked.updateBooked(travel_details);
}
}
- Mike Cerruti
- April 28, 2015
- Like
- 0
- Continue reading or reply
How to test this apex class?
This is my apex class;
Does anyone know how to test this apex class and increase the coverage code? I really will appreciate any help
public with sharing class FacturaPDFController {
public final Factura__c fct;
public cFactura cfct{get; set;}
public OT__c ots{get; set;}
public xOT otts {get; set;}
public Integer total{get; set;}
public List<cOT> cOTList{get;set;}
public List<cLdd> cLddList{get;set;}
public FacturaPDFController(ApexPages.StandardController controller) {
this.fct = [Select Id, Pre_Factura__r.ST_Exentas__c, Pre_Factura__r.Descuento__c, Pre_Factura__r.ST_Gravadas_IVA10__c, Pre_Factura__r.Total_a_Pagar__c, Pre_Factura__r.IVA_10__c From Factura__c Where Id = :controller.getId()];
this.cfct = new cFactura(this.fct);
total = Integer.valueOf( this.fct.Pre_Factura__r.Total_a_Pagar__c );
//OT personalizado
this.ots= [Select Cant_1__c,Cant_2__c,Cant_3__c,Cant_4__c,Cant_5__c, Texto_1_fact__c,Texto_2_fact__c,Texto_3_fact__c,
Texto_4_fact__c,Texto_5_fact__c, Precio_Unit_1__c, Precio_Unit_2__c, Precio_Unit_3__c, Precio_Unit_4__c, Precio_Unit_5__c,
Total_Ex_1__c, Total_Ex_2__c, Total_Ex_3__c, Total_Ex_4__c, Total_Ex_5__c,
Total_Gra_1__c, Total_Gra_2__c, Total_Gra_3__c, Total_Gra_4__c, Total_Gra_5__c
from OT__c where Pre_Factura__c = :this.fct.Pre_Factura__r.id];
this.otts=new xOT(this.ots);
//OT List
this.cOTList = new List<cOT>();
for(OT__c o : [Select Id, Codigo_2__c, Cantidad_2__c, Descripcion_2__c, Sub_Total__c, Exentas_2__c, Gravadas_IVA_10_2__c
from OT__c where Pre_Factura__c = :this.fct.Pre_Factura__r.id LIMIT 10]){
cOTList.add(new cOT(o));
}
//LDD List
this.cLddList = new List<cLdd>();
for(Linea_de_detalle__c l : [Select Q__c, P_Unit_Linea__c, Total_Exentas__c, Total_Gravadas_IVA_10__c, Producto__r.Codigo__c, Producto__r.Descripcion__c from Linea_de_detalle__c Where OT__r.Pre_Factura__c = :this.fct.Pre_Factura__r.id LIMIT 10]){
cLddList.add(new cLdd(l));
}
}
public String getNumberToWords(){
return NumberToSpanishWords.toSpanishWords( total );
}
public class cFactura{
public Factura__c fct{get; set;}
public String ST_Exentas{get;set;}
public String ST_Gravadas_IVA10{get;set;}
public String Total_a_Pagar{get;set;}
public String IVA_10{get;set;}
public String Descuento{get;set;}
public cFactura(Factura__c f){
this.fct = f;
this.ST_Exentas = NumberToSpanishWords.convertToEU(f.Pre_Factura__r.ST_Exentas__c);
this.ST_Gravadas_IVA10 = NumberToSpanishWords.convertToEU(f.Pre_Factura__r.ST_Gravadas_IVA10__c);
this.Total_a_Pagar = NumberToSpanishWords.convertToEU(f.Pre_Factura__r.Total_a_Pagar__c);
this.IVA_10 = NumberToSpanishWords.convertToEU(f.Pre_Factura__r.IVA_10__c);
this.Descuento = NumberToSpanishWords.convertToEU(f.Pre_Factura__r.Descuento__c);
}
}
public class xOT{ //valores que se usa para la OT personalizada
public OT__c ots{get; set;}
public string cantper1 {get; set;}
public string cantper2 {get; set;}
public string cantper3 {get; set;}
public string cantper4 {get; set;}
public string cantper5 {get; set;}
public string precio1 {get; set;}
public string precio2 {get; set;}
public string precio3 {get; set;}
public string precio4 {get; set;}
public string precio5 {get; set;}
public string totalexenta1 {get; set;}
public string totalexenta2 {get; set;}
public string totalexenta3 {get; set;}
public string totalexenta4 {get; set;}
public string totalexenta5 {get; set;}
public string totalgravada1 {get; set;}
public string totalgravada2 {get; set;}
public string totalgravada3 {get; set;}
public string totalgravada4 {get; set;}
public string totalgravada5 {get; set;}
public xOT(OT__c ot2) {
this.ots=ot2;
this.cantper1= NumberToSpanishWords.convertToEU(ot2.Cant_1__c);
this.cantper2= NumberToSpanishWords.convertToEU(ot2.Cant_2__c);
this.cantper3= NumberToSpanishWords.convertToEU(ot2.Cant_3__c);
this.cantper4= NumberToSpanishWords.convertToEU(ot2.Cant_4__c);
this.cantper5= NumberToSpanishWords.convertToEU(ot2.Cant_5__c);
this.precio1=NumberToSpanishWords.convertToEU(ot2.Precio_Unit_1__c);
this.precio2=NumberToSpanishWords.convertToEU(ot2.Precio_Unit_2__c);
this.precio3=NumberToSpanishWords.convertToEU(ot2.Precio_Unit_3__c);
this.precio4=NumberToSpanishWords.convertToEU(ot2.Precio_Unit_4__c);
this.precio5=NumberToSpanishWords.convertToEU(ot2.Precio_Unit_5__c);
this.totalexenta1=NumberToSpanishWords.convertToEU(ot2.Total_Ex_1__c);
this.totalexenta2=NumberToSpanishWords.convertToEU(ot2.Total_Ex_2__c);
this.totalexenta3=NumberToSpanishWords.convertToEU(ot2.Total_Ex_3__c);
this.totalexenta4=NumberToSpanishWords.convertToEU(ot2.Total_Ex_4__c);
this.totalexenta5=NumberToSpanishWords.convertToEU(ot2.Total_Ex_5__c);
this.totalgravada1=NumberToSpanishWords.convertToEU(ot2.Total_Gra_1__c);
this.totalgravada2=NumberToSpanishWords.convertToEU(ot2.Total_Gra_2__c);
this.totalgravada3=NumberToSpanishWords.convertToEU(ot2.Total_Gra_3__c);
this.totalgravada4=NumberToSpanishWords.convertToEU(ot2.Total_Gra_4__c);
this.totalgravada5=NumberToSpanishWords.convertToEU(ot2.Total_Gra_5__c);
}
}
public class cOT{ //valores que se usa para cuando la Pre_Factura tiene mas de una OT
public OT__c OT{get; set;}
public String Sub_Total{get;set;}
public String Exentas_2{get;set;}
public String Gravadas_IVA_10_2{get;set;}
public cOT(OT__c o){
this.OT = o;
this.Sub_Total = NumberToSpanishWords.convertToEU(o.Sub_Total__c);
this.Exentas_2 = NumberToSpanishWords.convertToEU(o.Exentas_2__c);
this.Gravadas_IVA_10_2 = NumberToSpanishWords.convertToEU(o.Gravadas_IVA_10_2__c);
}
}
public class cLdd{
public Linea_de_detalle__c LDD{get; set;}
public String P_Unit_Linea{get;set;}
public String Total_Exentas{get;set;}
public String Total_Gravadas_IVA_10{get;set;}
public cLdd(Linea_de_detalle__c l){
this.LDD = l;
this.P_Unit_Linea = NumberToSpanishWords.convertToEU(l.P_Unit_Linea__c);
this.Total_Exentas = NumberToSpanishWords.convertToEU(l.Total_Exentas__c);
this.Total_Gravadas_IVA_10 = NumberToSpanishWords.convertToEU(l.Total_Gravadas_IVA_10__c);
}
}
}
this is the test that I diid but it gives me this error:
FacturaPDFControllerTest.testFacturaPDFController(), Details, System.QueryException: List has no rows for assigment to sObject Class.FacturaPDFController <ini>: line 21 column 1
Class.FacturaPDFControllerTest.testFacturaPDFController:line 22, column 1
@isTest
public class FacturaPDFControllerTest {
public static testMethod void testFacturaPDFController() {
Pre_Factura__c prefactura = new Pre_Factura__c ();
insert prefactura;
Factura__c fac = new Factura__c(Pre_Factura__c = prefactura.id);
/*Write code to populate fields. See my note below*/
fac.Pre_impreso__c=1234999;
fac.Pre_impreso_001_001__c=1234999;
fac.Pre_impreso_002_001__c=1234999;
fac.Pre_impreso_002_002__c=1234999;
fac.Pre_impreso_003_001__c=1234999;
fac.Caja__c='Caja 1';
fac.Serie__c='Serie 1';
fac.Sucursal__c='Maker Villa Morra';
insert fac;
ApexPages.StandardController fact = new ApexPages.StandardController(fac);
FacturaPDFController facts = new FacturaPDFController(fact);
facts.total=1000;
facts.getNumberToWords();
System.assert(facts.fct <> NULL);
}
}
- David Ovella
- April 28, 2015
- Like
- 0
- Continue reading or reply
Can anyone help me to test this apex class?
This is my apex class;
Does anyone know how to test this apex class? I really will appreciate any help
public with sharing class FacturaPDFController {
private final Factura__c fct;
public cFactura cfct{get; set;}
public OT__c ots{get; set;}
public xOT otts {get; set;}
public Integer total{get; set;}
public List<cOT> cOTList{get;set;}
public List<cLdd> cLddList{get;set;}
public FacturaPDFController(ApexPages.StandardController controller) {
this.fct = [Select Id, Pre_Factura__r.ST_Exentas__c, Pre_Factura__r.Descuento__c, Pre_Factura__r.ST_Gravadas_IVA10__c, Pre_Factura__r.Total_a_Pagar__c, Pre_Factura__r.IVA_10__c From Factura__c Where Id = :controller.getId()];
this.cfct = new cFactura(this.fct);
total = Integer.valueOf( this.fct.Pre_Factura__r.Total_a_Pagar__c );
//OT personalizado
this.ots= [Select Cant_1__c,Cant_2__c,Cant_3__c,Cant_4__c,Cant_5__c, Texto_1_fact__c,Texto_2_fact__c,Texto_3_fact__c,
Texto_4_fact__c,Texto_5_fact__c, Precio_Unit_1__c, Precio_Unit_2__c, Precio_Unit_3__c, Precio_Unit_4__c, Precio_Unit_5__c,
Total_Ex_1__c, Total_Ex_2__c, Total_Ex_3__c, Total_Ex_4__c, Total_Ex_5__c,
Total_Gra_1__c, Total_Gra_2__c, Total_Gra_3__c, Total_Gra_4__c, Total_Gra_5__c
from OT__c where Pre_Factura__c = :this.fct.Pre_Factura__r.id];
this.otts=new xOT(this.ots);
//OT List
this.cOTList = new List<cOT>();
for(OT__c o : [Select Id, Codigo_2__c, Cantidad_2__c, Descripcion_2__c, Sub_Total__c, Exentas_2__c, Gravadas_IVA_10_2__c
from OT__c where Pre_Factura__c = :this.fct.Pre_Factura__r.id LIMIT 10]){
cOTList.add(new cOT(o));
}
//LDD List
this.cLddList = new List<cLdd>();
for(Linea_de_detalle__c l : [Select Q__c, P_Unit_Linea__c, Total_Exentas__c, Total_Gravadas_IVA_10__c, Producto__r.Codigo__c, Producto__r.Descripcion__c from Linea_de_detalle__c Where OT__r.Pre_Factura__c = :this.fct.Pre_Factura__r.id LIMIT 10]){
cLddList.add(new cLdd(l));
}
}
public String getNumberToWords(){
return NumberToSpanishWords.toSpanishWords( total );
}
public class cFactura{
public Factura__c fct{get; set;}
public String ST_Exentas{get;set;}
public String ST_Gravadas_IVA10{get;set;}
public String Total_a_Pagar{get;set;}
public String IVA_10{get;set;}
public String Descuento{get;set;}
public cFactura(Factura__c f){
this.fct = f;
this.ST_Exentas = NumberToSpanishWords.convertToEU(f.Pre_Factura__r.ST_Exentas__c);
this.ST_Gravadas_IVA10 = NumberToSpanishWords.convertToEU(f.Pre_Factura__r.ST_Gravadas_IVA10__c);
this.Total_a_Pagar = NumberToSpanishWords.convertToEU(f.Pre_Factura__r.Total_a_Pagar__c);
this.IVA_10 = NumberToSpanishWords.convertToEU(f.Pre_Factura__r.IVA_10__c);
this.Descuento = NumberToSpanishWords.convertToEU(f.Pre_Factura__r.Descuento__c);
}
}
public class xOT{ //valores que se usa para la OT personalizada
public OT__c ots{get; set;}
public string cantper1 {get; set;}
public string cantper2 {get; set;}
public string cantper3 {get; set;}
public string cantper4 {get; set;}
public string cantper5 {get; set;}
public string precio1 {get; set;}
public string precio2 {get; set;}
public string precio3 {get; set;}
public string precio4 {get; set;}
public string precio5 {get; set;}
public string totalexenta1 {get; set;}
public string totalexenta2 {get; set;}
public string totalexenta3 {get; set;}
public string totalexenta4 {get; set;}
public string totalexenta5 {get; set;}
public string totalgravada1 {get; set;}
public string totalgravada2 {get; set;}
public string totalgravada3 {get; set;}
public string totalgravada4 {get; set;}
public string totalgravada5 {get; set;}
public xOT(OT__c ot2) {
this.ots=ot2;
this.cantper1= NumberToSpanishWords.convertToEU(ot2.Cant_1__c);
this.cantper2= NumberToSpanishWords.convertToEU(ot2.Cant_2__c);
this.cantper3= NumberToSpanishWords.convertToEU(ot2.Cant_3__c);
this.cantper4= NumberToSpanishWords.convertToEU(ot2.Cant_4__c);
this.cantper5= NumberToSpanishWords.convertToEU(ot2.Cant_5__c);
this.precio1=NumberToSpanishWords.convertToEU(ot2.Precio_Unit_1__c);
this.precio2=NumberToSpanishWords.convertToEU(ot2.Precio_Unit_2__c);
this.precio3=NumberToSpanishWords.convertToEU(ot2.Precio_Unit_3__c);
this.precio4=NumberToSpanishWords.convertToEU(ot2.Precio_Unit_4__c);
this.precio5=NumberToSpanishWords.convertToEU(ot2.Precio_Unit_5__c);
this.totalexenta1=NumberToSpanishWords.convertToEU(ot2.Total_Ex_1__c);
this.totalexenta2=NumberToSpanishWords.convertToEU(ot2.Total_Ex_2__c);
this.totalexenta3=NumberToSpanishWords.convertToEU(ot2.Total_Ex_3__c);
this.totalexenta4=NumberToSpanishWords.convertToEU(ot2.Total_Ex_4__c);
this.totalexenta5=NumberToSpanishWords.convertToEU(ot2.Total_Ex_5__c);
this.totalgravada1=NumberToSpanishWords.convertToEU(ot2.Total_Gra_1__c);
this.totalgravada2=NumberToSpanishWords.convertToEU(ot2.Total_Gra_2__c);
this.totalgravada3=NumberToSpanishWords.convertToEU(ot2.Total_Gra_3__c);
this.totalgravada4=NumberToSpanishWords.convertToEU(ot2.Total_Gra_4__c);
this.totalgravada5=NumberToSpanishWords.convertToEU(ot2.Total_Gra_5__c);
}
}
public class cOT{ //valores que se usa para cuando la Pre_Factura tiene mas de una OT
public OT__c OT{get; set;}
public String Sub_Total{get;set;}
public String Exentas_2{get;set;}
public String Gravadas_IVA_10_2{get;set;}
public cOT(OT__c o){
this.OT = o;
this.Sub_Total = NumberToSpanishWords.convertToEU(o.Sub_Total__c);
this.Exentas_2 = NumberToSpanishWords.convertToEU(o.Exentas_2__c);
this.Gravadas_IVA_10_2 = NumberToSpanishWords.convertToEU(o.Gravadas_IVA_10_2__c);
}
}
public class cLdd{
public Linea_de_detalle__c LDD{get; set;}
public String P_Unit_Linea{get;set;}
public String Total_Exentas{get;set;}
public String Total_Gravadas_IVA_10{get;set;}
public cLdd(Linea_de_detalle__c l){
this.LDD = l;
this.P_Unit_Linea = NumberToSpanishWords.convertToEU(l.P_Unit_Linea__c);
this.Total_Exentas = NumberToSpanishWords.convertToEU(l.Total_Exentas__c);
this.Total_Gravadas_IVA_10 = NumberToSpanishWords.convertToEU(l.Total_Gravadas_IVA_10__c);
}
}
}
- David Ovella
- April 28, 2015
- Like
- 0
- Continue reading or reply
How to insert custom objects with a lookup to itself
global with sharing class QuestionRestController{
global class RequestBody {
global List<Question__c> questions;
}
@HttpPost
global static List<Question__c> createBulk(QuestionRestController.RequestBody req) {
insert req.questions;
return req.questions;
}
}
I get this error: System.DmlException: Insert failed. First exception on row 94; first error: INVALID_FIELD, Foreign key external ID: 966.0 not found for field MyExtId__c in entity Question__c no matter what I try.
I figured I could sort the questions before sending the request so that the parent questions are always inserted first but I still get the errors. I've added debug statements so I could verify the order of the questions prior to inserting and they are ordered correctly. I've also tried to insert each question by itself:
for (Question__c question: req.questions) {
insert question;
}
But then I get a System.LimitException because I'm sending 200+ questions.
So what is the proper way to insert a list of custom objects which have a lookup to itself when the parent and child are both being inserted with the same request?
Thanks
- Neil Smith 10
- April 27, 2015
- Like
- 1
- Continue reading or reply
Metadata downloads workflow files but not contact.workflow
I looked through the logs and saw some Java exceptions at the time of a metadata refresh but they didn't give me a clue as to why this would be happening. Does anybody have any clues as to why some metadata components would be downloaded while others aren't being downloaded?
Thanks!!
- Vinnie B
- November 18, 2014
- Like
- 0
- Continue reading or reply
How can you prevent future functions from locking out other future functions?
Occassionally, I'll get a message about locked rows. This is, of course, quite bad as some of my updates just don't happen.
I did some other coding with batch files and got around this by having Batch-1 call Batch-2 which calls Batch-3, etc. Is there some way to make sure five different future calls won't run at the same time?
Thanks!
- Vinnie B
- July 31, 2014
- Like
- 0
- Continue reading or reply
Apex Code Coverage issue
I have 95% covergae in production , and I moving classes/triggers that have (97%) coverage in dev.
Whan I deploy in production , I am getting the error
Code Coverage Failure
Your organization's code coverage is 73%. You need at least 75% coverage to complete this deployment.
what am I missing here !?
Thanks
- Yousef Bayari 7
- July 31, 2014
- Like
- 0
- Continue reading or reply
redirect to same page
Could u please help me in the following scnearios -
1. I have a vf page which displays list of cases with a picklist in each row and a save button. I want when i press save button it will save the record and redirect me to the same page.
Currently i am not using any custom controller and the save button after click is re-directing to home page.
- ❤Code
- July 17, 2014
- Like
- 0
- Continue reading or reply
Changes in test class processing with Summer '14 release?
I checked and the test code on production hasn't been changed since February but just started failing this week.
Any ideas? Thanks!!
- Vinnie B
- July 16, 2014
- Like
- 0
- Continue reading or reply
Can not see Account field value in Contact trigger in test method
I have a simple test method which creates an Account and a Contact. A trigger on Contact which sets a field based on the Account's BillingState. Problem is when the trigger fires the Billing state evelautes to null. I cannot understand as to why. Here is test method setting these up.
test method:
static testMethod void validate() {
Test.startTest();
account[] accounts = new account[]{
new account(name='highschool',BillingState='CA',BillingPostalCode='92100') };
insert accounts;
contact[] contacts = new contact[] {
new contact(LastName='Sand10',TargetX_SRMb__Student_Type__c='New Freshman',accountId=accounts[0].id)};
insert contacts;
Test.stopTest();
List<contact> con = [select id, LastName, FirstName,TargetX_SRMb__Student_Type__c,TargetX_SRMb__College__c,account.BillingState, account.billingPostalCode,Territory_Assignments__c from Contact];
for(Contact e: con) {
System.debug('Last name.......... '+e.lastname+' State '+e.account.BillingState); // this actually DOES return BillingState
}
In trigger logic:
...
if(String.isNotBlank(c.TargetX_SRMb__Student_Type__c) ){
system.debug('lastname in trigger: '+c.lastname+' state is '+c.account.billingState); // this shows null for BillingState
//look at territory state
if(String.isNotBlank(c.Account.BillingState)){
system.debug('not blank'); // never get here
.....
Thanks,
Jon
- jonpilarski1.3914448382645588E12
- July 16, 2014
- Like
- 0
- Continue reading or reply