-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
19Questions
-
41Replies
Using Sales Force Apex API, how do I create a Scheduled Workflow
Using Apex Api, I need to create a scheduled workflow programmatically. I downloaded Apex Api locally on my system but where exactly do I need to download the api so that I can call/ use those functions that are already defined in the API. Where do I write a script/ create a cron job. Do I write that in a class. I am clueless.
If somebody can tell me the steps that would be great. Please let me know at the earliest.
thanks,
kathyani
- kathyani
- December 22, 2008
- Like
- 0
- Continue reading or reply
No rows assigned to SObject
Case 2 --- List <ABC__c> a = [select a.Id, a.name from A where a.label = 'apex'];
In case of Case 1 , if there is no matching record then it throws an exception when run (no row assigned to Sobject) whereas Case 2 does not throw an exception.
For now I am using syntax of Case 2 in my coding but how can I make the code (Case 1) more efficient without having to use a list as defined in Case 2.
I need to use this in many places, any help would be appreciated.
thanks,
kathyani
- kathyani
- December 18, 2008
- Like
- 0
- Continue reading or reply
Scheduled Workflow
I need to create a scheduled work flow which should fire a trigger and alert the user that something has happened. Also it should create a record in a table.
I searched for documentation but the steps are not clear. I vaguely understood the concept but what are the steps? Can somebody send me an example and steps to accomplish this? What do I click sales force UI to create a scheduled workflow?
Thanks,
Kathyani
- kathyani
- December 15, 2008
- Like
- 0
- Continue reading or reply
FieldType is displayed as double instead of an Integer
I created a table in Sales force and for one of the fields I chose Number as data type. When I view the table in eclipse the field is displaying double as its data type. I do not want that field to be declared as double just need to be an Integer.
I did say 0 for Decimal Places while creating the field in Sales force.
How can I solve this, quick help would be appreciated.
kathyani
- kathyani
- December 11, 2008
- Like
- 0
- Continue reading or reply
FieldType is displayed as double instead of an Integer
I created a table in SF and for one of the fields I chose Number as data type. When I view the table in eclipse the field is displaying double as its data type. I do not want that field to be declared as double just need to be an Integer.
How can I solve this, quick help would be appreciated.
kathyani
- kathyani
- December 10, 2008
- Like
- 0
- Continue reading or reply
Test Method: System.Exception
I am creating a test method where I am saying insert department, insert employee, insert deviceservice, insert bill. This calls department trigger code, employee trigger code, billbefore and billafter trigger code. As it calling so many triggers there is lot of code that is getting executed. From apex debugger I am seeing that there are lot of rows retrieved from all these SOQL queries that are defined in all these triggers. So it retrieves lot of SOQL rows. Because of this I am getting System.Exception.
I do not want to add limit in any of the SOQL queries. Is there any other way to solve this. Is there a way that I can tell it to not execute code that is not required. or Do I need to split these into different test methods?
Thanks in advance,
kathyani
- kathyani
- December 04, 2008
- Like
- 0
- Continue reading or reply
How do I delete triggers from salesforce
I had EmployeeBefore and EmployeeAfter triggers. I deleted them from Eclipse but how do I get rid of it in SF. I created a new trigger called EmployeeTrigger. When I run tests it is still executing those two deleted triggers along with Employee Trigger. So for some reason I need to delete it from Salesforce. Under src, I right clicked on Triggers and said save to server but it is still executing both before and after triggers.
Quick help would be appreciated.
thanks in advance,
kathyani
- kathyani
- December 04, 2008
- Like
- 0
- Continue reading or reply
Unit Tests: System.Exception: Too many query rows
This is the error I am seeing:
.EmployeeTrigger: line 12, column 33: SOQL query with 49 rows finished in 4 ms
System.Exception: Too many query rows: 532
Trigger.EmployeeTrigger: line 12, column 33
It is failing at this line [select d.Id, d.Name__c from Department__c d] in employeetrigger.
I am not clear with the line System.Exception: Too many query rows: 532. Where is it getting this number 532 from when there are only 49 rows being queried from the table.
Please let me know.
- kathyani
- November 26, 2008
- Like
- 0
- Continue reading or reply
Apex Unit Tests
To view test coverage:
Eclipse -> Project- > src -> unpackaged -> classes -> Force.com -> run tests.
Under Failures and warnings and under general warnings it was showing 64% completed but 75 % test coverage is required.
Then I added one more test in a class as I am trying to reach for at least 85% test coverage but now when I right click to run tests I am seeing few failures and warnings but not seeing the the general warnings tab as before.
What does it mean? How can I see what percentage I have covered?
thanks,
kathyani
- kathyani
- November 21, 2008
- Like
- 0
- Continue reading or reply
System.Exception: Too many query rows: 540
System.Exception: Too many query rows: 540
Trigger.EmployeeTrigger: line 40, column 62
Below is line 40 in the code.
Map<ID, Employee__c> emps = new Map<ID, Employee__c>([select e.Id, e.Supervisor__c, e.Name from Employee__c e]);
Because of this when I say insert emp in my test method it displays the error "cannot insert update activity entity".
Can somebody please quickly help me?
thanks,
kathyani
- kathyani
- November 20, 2008
- Like
- 0
- Continue reading or reply
Import look up data from one environment (sandbox) to another environment (staging)
When importing large amounts of data from one environment to another and if that data has look up data as its field value then this would not work because of the record id mismatch. The new environment would have a record id generated that is different from the record id of old environment.
I did the below steps and it worked but is this the correct way to do it. Please let me know.
In Sandbox:
I created a table called Parent.
I created a table
called Child that has Parent as its look up
table.
I exported data using reports from
Sandbox for tables: Parent and Child and saved it on my desktop. So this is the data
which needs to go into production.
In Production:
I created a custom field External ID fields for Parent table. When creating this field I checked the check box External ID (which is unique /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> (belbelow the unique and required check boxes).
I imported data into Parent by mapping the External_ID__c of this table to the Parent: ID from csv file (Parent: ID from Sandbox).
Now in production I have
External_ID__c of Parent (Production) = ID of Parent (Sandbox)
To import child records, logged into data loader
2. Select Child table
3. Click 'Next' on Select the field for matching on Child__c
4. Select External_Id__c for the parent
5. Click 'Create or Edit a Map' and map the fields (
6. Perform upsert.
- kathyani
- November 14, 2008
- Like
- 0
- Continue reading or reply
Trigger : Test Coverage results
DepartmentTrigger (ApexTrigger) - 1 lines not tested, 94% covered
TestDepartmentTrigger (ApexClass) - 0 lines not tested, 100% covered.
What does the above mean. Did I write my test method correctly or not? Please let me know, quick help would be appreciated.
thanks,
kathyani
- kathyani
- November 12, 2008
- Like
- 0
- Continue reading or reply
Test Coverage
I am trying to create a testMethod for test coverage of a functionality. Test method name cannot have parameters. How do we call a method which has parameters inside this test method?
Example:
static testMethod void testgenerateActivityForSuspendedBill() {
createCurrentDS(dsList, date.newInstance(2007, 10, 01), date.newInstance(2007, 10, 31), '(111) 555-5555') ;
}
Severity and Description Path Resource Location Creation Time Id
Save error: Method does not exist or incorrect signature: createCurrentDS(LIST:SOBJECT:DeviceService__c, Date, Date, String) DMPortal2_Apex_Staging/src/unpackaged/classes ActivityService.cls line 151 1226525337544 22864
What is the mistake I am doing?
Quick help would be appreciated.
thanks,
kathyani
- kathyani
- November 12, 2008
- Like
- 0
- Continue reading or reply
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id
I never had problems running my test method on my developer's edition before.
But now I created a new salesforce account and have all my triggers here. I am getting an error when I run my test method on this newly created instance.
Error:
DML Operation executed in 180 ms
System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id
Do I need to set some rights/roles or privileges on this newly created account? Quick help would be appreciated.
Thanks,
Kathyani
- kathyani
- November 05, 2008
- Like
- 0
- Continue reading or reply
Look up tables
- kathyani
- October 29, 2008
- Like
- 0
- Continue reading or reply
Error while logging into data loader: API is not enabled for this Organization or Partner
Now I registered with a new user/ email address. Its a developers instance. I am trying to login into Apex dataloader using this new id and am getting an error "API is not enabled for this Organization or Partner". Do I need to set any role somewhere. If so please tell me the steps also because I am still new using salesforce developer instance website.
Can somebody help me asap?
thanks,
kathyani
- kathyani
- October 29, 2008
- Like
- 0
- Continue reading or reply
Load data which have fields as look up - data loader only takes ID for that field
I want to insert data into salesforce using dataloader. So I created an excel file with data. Few of the fields are look up fields so my excel file has the ID as the value in that field. This works for me but I want to share this data with my team mates and we will need to change the ID for these fields corresponding to their instance. ID is a foreign key/look up in another table.
Also data loader takes only ID for these look up fields. If I have a label value instead of ID it does not insert data.
Example
Field1 | Field1 | Field3 | Field4 | Subject | ActionLabel | ||
a0C80000001Qfxm | a0C80000001PqoE | a0C80000001Qfxe | text1 | FieldInquiry SuspendedUsage Email | |||
a0C80000001QjWE | a0C80000001PqoE | a0C80000001Qfxe | text2 | FieldGeneral SuspendedUsage Email |
If we have huge data then it would not be possible to load same data. How can we achieve this so that one set of data can be used across multiple instances.
Quick response would be appreciated.
thanks,
kathyani
- kathyani
- October 22, 2008
- Like
- 0
- Continue reading or reply
Is there a maximum limit for number of sobjects that can be created?
Is there a maximum limit for number of sobjects/ tables that can be created in sales force DB ?
Is there a number for the max limit, did not find this in governor limits.
Quick reply would be appreciated. Thanks in advance.
regards,
kathyani
- kathyani
- October 17, 2008
- Like
- 0
- Continue reading or reply
Trying to map in memory
I have an two objects Object A and Object B.
I created a map between Object A and Object B so that the Id of Object A is assigned to ParentId of Object B.
Object B.ParentId= Object A.Id - this is the goal. Assignment should happen in Map itself even before insert happens.
Steps:
Created a Map which links both objects.
insert Object A;
insert Object B;
Id in Object A gets generated only after it is inserted in the db. When I do this ParentId value is still displayed as null. So basically it is not getting Object A' Id value.
Can somebody help me soon?
- kathyani
- September 12, 2008
- Like
- 0
- Continue reading or reply
!!!!Record is not inserted!!!!
I have two objects prac__c, Dept__c.
I wrote a trigger for prac__c which calls a method m1() in pracs_prac1.class when a record is created/updated in prac__c object
Apex class shown below:
public class pracs_prac1 {
public static void m1(prac__c[] a1)
{
Dept__c dpt=new Dept__c(Name='testing');
try
{
insert dpt;
}
catch(DMLException e)
{
system.assert(false,'Error creating Calc:'+e.getDMLMessage(0));
}
}
}
This class is compiled successfully without any error.
But when i created a record in prac__c no record is inserted in Dept__c
Is there any createable property set to be true?
when i used the statement: Dept__c.createable=true; in the above class getting an error saying Save error: Variable does not exist: Dept__c.createable
then how can i set the createable property to true?
Is there any code i have to use apart from this? Please help me in this regard.
Thanks in advance,
-Vissu
- crocodile
- December 23, 2008
- Like
- 0
- Continue reading or reply
Scheduled Workflow
I need to create a scheduled work flow which should fire a trigger and alert the user that something has happened. Also it should create a record in a table.
I searched for documentation but the steps are not clear. I vaguely understood the concept but what are the steps? Can somebody send me an example and steps to accomplish this? What do I click sales force UI to create a scheduled workflow?
Thanks,
Kathyani
- kathyani
- December 15, 2008
- Like
- 0
- Continue reading or reply
FieldType is displayed as double instead of an Integer
I created a table in Sales force and for one of the fields I chose Number as data type. When I view the table in eclipse the field is displaying double as its data type. I do not want that field to be declared as double just need to be an Integer.
I did say 0 for Decimal Places while creating the field in Sales force.
How can I solve this, quick help would be appreciated.
kathyani
- kathyani
- December 11, 2008
- Like
- 0
- Continue reading or reply
FieldType is displayed as double instead of an Integer
I created a table in SF and for one of the fields I chose Number as data type. When I view the table in eclipse the field is displaying double as its data type. I do not want that field to be declared as double just need to be an Integer.
How can I solve this, quick help would be appreciated.
kathyani
- kathyani
- December 10, 2008
- Like
- 0
- Continue reading or reply
How do I delete triggers from salesforce
I had EmployeeBefore and EmployeeAfter triggers. I deleted them from Eclipse but how do I get rid of it in SF. I created a new trigger called EmployeeTrigger. When I run tests it is still executing those two deleted triggers along with Employee Trigger. So for some reason I need to delete it from Salesforce. Under src, I right clicked on Triggers and said save to server but it is still executing both before and after triggers.
Quick help would be appreciated.
thanks in advance,
kathyani
- kathyani
- December 04, 2008
- Like
- 0
- Continue reading or reply
Unit Tests: System.Exception: Too many query rows
This is the error I am seeing:
.EmployeeTrigger: line 12, column 33: SOQL query with 49 rows finished in 4 ms
System.Exception: Too many query rows: 532
Trigger.EmployeeTrigger: line 12, column 33
It is failing at this line [select d.Id, d.Name__c from Department__c d] in employeetrigger.
I am not clear with the line System.Exception: Too many query rows: 532. Where is it getting this number 532 from when there are only 49 rows being queried from the table.
Please let me know.
- kathyani
- November 26, 2008
- Like
- 0
- Continue reading or reply
Trigger/Unit Test Help
trigger RenewalOpportunity on Opportunity (after update) { for (Integer i = 0; i < Trigger.new.size(); i++) { if (Trigger.new[i].isWon == true && Trigger.old[i].isWon == false && Trigger.new[i].RenewalOpportunity__c == null) { Opportunity renewalOpp = Trigger.new[i].clone(false); Double x = Trigger.old[i].Contract_Length__c; Integer y = x.intValue(); renewalOpp.Name = 'Renewal - '+ Trigger.old[i].Name; renewalOpp.closedate = Trigger.old[i].Contract_Activation_Date__c.addmonths(y); renewalOpp.stagename = '0 - Very Early Stage'; renewalOpp.probability = 0; renewalOpp.ForecastCategoryName = 'Pipeline'; renewalOpp.Contract_Activation_Date__c = null; renewalOpp.Contract_Length__c = null; insert renewalOpp; if (Trigger.old[i].Name.startsWith('Renewal - ')) { renewalOpp.Name = Trigger.old[i].Name; update renewalOpp; } if (Trigger.new[i].isWon == true && Trigger.old[i].isWon == false && Trigger.new[i].RenewalOpportunity__c == null) { Opportunity newOpp = [select ID from Opportunity where id = :Trigger.new[i].ID]; newOpp.RenewalOpportunity__c = renewalOpp.ID; update newOpp; } } } }
Unit Test
public class CreateOpportunity { static testMethod void testCreateOpportunityRenewal(){ // Test opportunities moving from isWon = false to isWon = true try { Double Contract_Length = 13; Double x = Contract_Length; Integer y = x.intValue(); Date today = System.today(); Date contract_activation_date = System.today(); Date closeDate = contract_activation_date.addmonths(y); Opportunity opportunity = new Opportunity(); opportunity.name = 'old opportunity name'; opportunity.Contract_Length__c = 13; opportunity.contract_activation_date__c = today; opportunity.closedate = today; opportunity.stagename = 'Closed Lost'; opportunity.probability = 1; opportunity.ForecastCategoryName = 'Closed'; insert opportunity; System.assertEquals(opportunity.name, 'old opportunity name'); opportunity.stagename = 'Closed Won'; update opportunity; Opportunity updatedOpportunity = [select ID,RenewalOpportunity__c from Opportunity where id = :opportunity.ID]; // go get new opportunity System.debug('opportunityId: ' + updatedOpportunity.RenewalOpportunity__c); Opportunity newOpportunity = [select ID, Name, Contract_Length__c, contract_activation_date__c, closedate, stagename, probability, forecastCategoryName from Opportunity where id = :updatedOpportunity.RenewalOpportunity__c]; System.assertNotEquals(newOpportunity, null); System.assertEquals(newOpportunity.name, 'Renewal - old opportunity name'); System.assertEquals(newOpportunity.Contract_Length__c, 12); System.assertEquals(newOpportunity.contract_activation_date__c, today); System.assertEquals(newOpportunity.closedate, closeDate); System.assertEquals(newOpportunity.stagename, '0 - Very Early Stage'); System.assertEquals(newOpportunity.probability, 0); System.assertEquals(newOpportunity.ForecastCategoryName, 'Pipeline'); delete opportunity; } catch (DmlException e) { System.assert(false); } // Test opportunities moving from isWon = false to isWon = false try { Double Contract_Length = 13; Double x = Contract_Length; Integer y = x.intValue(); Date today = System.today(); Date contract_activation_date = System.today(); Date closeDate = contract_activation_date.addmonths(y); Opportunity opportunity = new Opportunity(); opportunity.Contract_Length__c = 13; opportunity.contract_activation_date__c = today; opportunity.name = 'old opportunity name'; opportunity.closedate = today; opportunity.stagename = 'Closed Lost'; opportunity.probability = 1; opportunity.ForecastCategoryName = 'Closed'; insert opportunity; System.assertEquals(opportunity.name, 'old opportunity name'); opportunity.stagename = 'Final Steps'; update opportunity; Opportunity updatedOpportunity = [select ID,RenewalOpportunity__c from Opportunity where id = :opportunity.ID]; try { Opportunity newOpportunity = [select ID from Opportunity where id = :updatedOpportunity.RenewalOpportunity__c]; System.assert(false); } catch (Exception e) { } delete opportunity; } catch (DmlException e) { System.assert(false); } } }
- jladders
- November 21, 2008
- Like
- 0
- Continue reading or reply