• kathyani
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 41
    Replies
Hi,


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
Case 1 --- ABC__c  a = [select a.Id, a.name from A where a.label = 'apex'];

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



Hi,

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

Hi,

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
Hi,

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
Hi,

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



Hi,

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
I am creating a unit test and I have insert employeeList which has a list of employees.

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.


I created unit tests for triggers and classes.

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
SOQL query with 243 rows finished in 11 ms
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

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

1. Select 'upsert'
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.
 


 


I created a test method for a trigger. After I run this method, under Code Coverage Results, it says
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
Hi,


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


Hi,

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
Using this tool, can we export look up tables into my mate's instance from my instance even though the record ids differ.
With my old user id (developers instance), I can login into Apex dataloader.
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
Hi,
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
Field1Field1Field3Field4

SubjectActionLabel
a0C80000001Qfxma0C80000001PqoEa0C80000001Qfxetext1


FieldInquiry SuspendedUsage Email
a0C80000001QjWEa0C80000001PqoEa0C80000001Qfxetext2

FieldGeneral SuspendedUsage Email
In this example Field1, Field2, Field3 are lookup fields in another table. They are foreign keys. So if my team mate wants to use the same data to export into their instance this would not work because they will have a different set of IDs on their instance.

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
Hi,


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
Hi,

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?
Hi all,
         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


Hi,

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

Hi,

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
Hi,

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
Hi,

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
I am creating a unit test and I have insert employeeList which has a list of employees.

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.


Any help/idea will be more than appreciated! I have a trigger that inserts a new opportunity record once stage is set to closedwon, it works fine until i try to set the newly inserted record to closewon. I get the following error message
 
System.NullPointerException: Attempt to de-reference a null object: Trigger.RenewalOpportunity: line 9, column 48
 
contract_length__c is a number field while contract_activation_date is a date field. below is the code I have so far
 
Trigger
Code:
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
 
Code:
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);
    }
  }
}

 
Thanks in adavance :)