• hector.asp2
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 21
    Replies
Hi,

I want to create a Task after saving a customer Object.
In my Customer Object I give a User FIeld: Editor.
I try with this Code

Code:
task.WhatId = Object.id;
task.WhoId = Object.Editor__c;
task.Subject = 'Other';
task.priority= Object.Priority__c;
task.status = 'Not Started';
task.description = 'New  Work';
insert task;

 And I become this failure:

Attempt to de-reference a null object

Do you have an Idea to help me?

Thx

Magda




Message Edited by magda on 02-13-2008 12:32 AM
  • February 08, 2008
  • Like
  • 0

I have a test case where I run batch process for account and lead records

 

The batch process for account does not run.

 

Here is the debug log for account

 

 

10:10:32.921|CODE_UNIT_STARTED|[EXTERNAL]|01pA0000001ORii|sds.AccountUpdaterBatch
10:10:32.923|METHOD_ENTRY|[19]|Database.getQueryLocator(String)
10:10:32.924|SOQL_EXECUTE_BEGIN|[19]|Aggregations:0|select id ,Name,SLASerialNumber__c from account
10:10:32.987|SOQL_EXECUTE_END|[19]|Rows:6
10:10:32.987|METHOD_EXIT|[19]|Database.getQueryLocator(String)
10:10:33.023|FATAL_ERROR|Internal Salesforce.com Error
10:10:33.023|CUMULATIVE_LIMIT_USAGE
10:10:33.023|LIMIT_USAGE_FOR_NS|sds|
Number of SOQL queries: 0 out of 200
Number of query rows: 0 out of 10000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 100
Number of DML rows: 0 out of 10000
Number of script statements: 1 out of 1000000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 1
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 0
Number of find similar calls: 0 out of 10
Number of System.runAs() invocations: 0 out of 20

10:10:33.023|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
10:10:33.023|CUMULATIVE_LIMIT_USAGE_END

10:10:33.023|CODE_UNIT_FINISHED|sds.AccountUpdaterBatch

 

 

 

 

 

Here is the debug log for lead

 

10:10:33.147|CODE_UNIT_STARTED|[EXTERNAL]|01pA0000001ORii|sds.AccountUpdaterBatch
10:10:33.148|METHOD_ENTRY|[19]|Database.getQueryLocator(String)
10:10:33.149|SOQL_EXECUTE_BEGIN|[19]|Aggregations:0|select id ,FirstName,LastName from lead
10:10:33.210|SOQL_EXECUTE_END|[19]|Rows:47
10:10:33.211|METHOD_EXIT|[19]|Database.getQueryLocator(String)
10:10:33.291|CUMULATIVE_LIMIT_USAGE
10:10:33.291|LIMIT_USAGE_FOR_NS|sds|
Number of SOQL queries: 0 out of 200
Number of query rows: 0 out of 10000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 100
Number of DML rows: 0 out of 10000
Number of script statements: 1 out of 1000000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 1
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 0
Number of find similar calls: 0 out of 10
Number of System.runAs() invocations: 0 out of 20

10:10:33.291|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
10:10:33.291|CUMULATIVE_LIMIT_USAGE_END

10:10:33.291|CODE_UNIT_FINISHED|sds.AccountUpdaterBatch

 

 

 

For accounts I get an error but I don't know why that error is there. The error line is in bold.

 

Please guide.

 

Thanks,

Hector....

 

Hi ,

 

I want to pass a record set generated from apex controller class constructor to ajax on a vf page. I dont want to fire same query at controller and VF. How can this be achieved.

 

Thanks

Bikram...

Hi All,

I wanted to save user clicks count on one particular button, and am thinking of custome settings. My need is very simple, a simple integer to save how many times a particular page was called etc... The count starts from 0 and only goes up to 5.

The examples is see for custome settings do not cover such a simple scenario..

Plus I need to be able to access that variable thru both apex and ajax.

 

Please guide

 

Thanks

Hector....

 

Hi All.

 

I am have trouble with governor limits when I run test cases for my application.

 

System.Exception: Too many SOQL queries: 21Trigger.dsContactTrigger: line 388, column 32

 

My application has 5 batch processes which I need to test and triggers on update insert and delete for account contact and lead.

 

Thanks

Hector.

Hi ,

 

I have a custom object in which I save the record type (it can be accounts, contacts, leads).

Here is my code

 

 

String obj='Contacts'; 
RecordType rt = [select id, name from recordtype where name =: obj limit 1];
System.Debug(rt.name); //Gives Contacts
savedGrp.RecordType = rt;
insert savedGrp;  

it always saves accounts...

 

 

 

 

Please help me with this.

 

Thanks

Hector.

Hi,

 

I have made a trigger for Account object called after insert. I need to warn the user that a duplicate record already exists when user enters any new Account record which is duplicate. How can this be done?

 

Thanks

Hector

Hi,

 

I have made a trigger and inside that trigger, I need to access saved data value, for field name stored in a string variable.

e.g. Account myAccount = trigger.new[0];

String fieldName = 'Fax';

myAccount.Fax works;

myAccount.fieldName gives error.

 

 

 

 

trigger dsAccountTrigger on Account (after insert) {
Account myAccount = trigger.new[0];

String query = 'select FieldName__c,MatchType__c from FieldMatchTypeRules__c where ObjectName = \'account\'';
matches = Database.query(query);

for(integer i = 0; i < matches.size(); i++)
{
String matchType = matches[i].MatchType__c;
String myFieldScore = '';

myFieldScore = myAccount.Fax;//This works
//This does not work
myFieldScore = myAccount.matches[i].FieldName__c;
//How to access field value saved in variable?
}
}

 

Do I need to have a different approach.

 

Please guide

 

Regards

Hector...

Hi All,

 

I am trying to Merge Contacts and Leads using the code example given below for Accounts.

 

 

List<Account> ls = new List<Account>{new Account(name='Acme Inc.'),new Account(name='Acme')};
insert ls;
Account masterAcct = [select id, name from account where name = 'Acme Inc.' limit 1];
Account mergeAcct = [select id, name from account where name = 'Acme' limit 1];
try {
merge masterAcct mergeAcct;
} catch (DmlException e) {
// Process exception here 

}

 

The above code works but when I code on similar lines and change Account to Lead or Contact. I get the error:

Compile Error: Field is not writeable: Contact.Name at line 66.....

Here is what I tried:

List<Contact> ls = new List<Contact>{new Contact(name='Classic Inc.'),new Contact(name='Classic')};
insert ls;
Contact masterAcct = [select id, name from contact where name = 'Classic Inc.' limit 1];
Contact mergeAcct = [select id, name from contact where name = 'Classic' limit 1];
try {
merge masterAcct mergeAcct;
} catch (DmlException e) {
// Process exception here 

}

 

 

 

Thankjs

Hector...

 

 

 

 

Hi All,

 

I got the following error

Compile Error: Field is not writeable: Contact.Name at line 66.....

Following is the code snippet

 

 

global class clsCustomWebService_MergeStdObject {

...................

...............

webService static String mergeContactStdObj (String MasterId, String Slave1Id, String Slave2Id)
{


..........//This statement works

List<Account> ls = new List<Account>{new Account(name='Acme Inc.'),new Account(name='Acme')};
insert ls;


................................


...............//This line generate the error

List<Contact> ls = new List<Contact>{new Contact(name='Classic Inc.'),new Contact(name='Classic')};
insert ls;



......................

}

.........................

}

 

The same fails for Lead too.

What I want to achieve is run the code example as given in the below mentioned link for Account, Lead and Contact.

Following is the ref documentation link

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_merge.htm

 

 

 

Thanks

Hector....

 

Hello All,

 

I want to use the api merge() method in this class. I created a apex class and I got the following error for this statement:

MergeRequest mr = new MergeRequest();

 

Error: Compile Error: Invalid type: MergeRequest at line 7 column 33

 

If any one could point what am I doing wrong and what should be my approach, I want to call this webservice through flex.

 

My reference document is

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_merge.htm

 

 

global class clsWbSrv_MyService {

    webService static String fnMyService (String StdObjType, String MasterId, String Slave1Id, String Slave2Id) {
        String Result ='';
    Account masterAccount = new Account();

    MergeRequest mr = new MergeRequest();

      .................
      .................
      .................


       Result +=StdObjType + ' ' + MasterId + ' ' + Slave1Id + ' ' + Slave2Id;
        return Result;  
    }

}

 

 

Thanks

Hector....

 

Hi folks

Any one have any idea how to deal this System.CalloutException: Read timed out error ?

 

 

Arun thakur

http://cumulusforce.appspot.com/

hi folks
i am looking to update and  insert  account information in flex using
Sforce Object Query Language (SOQL) but i am not able to find any valid solution online can you Please help me ?

i am using following code to select account information from SF

    private function loadData(lr:Object):void
            {
                //Select Name, Phone, Type From Account
                apex.query("insert (Name, Phone) Type From Account", new AsyncResponder(
                    function(qr:QueryResult):void {
                        if (qr.size > 0) {
                            accountList = qr.records;
                        }
                    },
                    handleFault)
                );
            }


Hi ,

 

I have a custom object in which I save the record type (it can be accounts, contacts, leads).

Here is my code

 

 

String obj='Contacts'; 
RecordType rt = [select id, name from recordtype where name =: obj limit 1];
System.Debug(rt.name); //Gives Contacts
savedGrp.RecordType = rt;
insert savedGrp;  

it always saves accounts...

 

 

 

 

Please help me with this.

 

Thanks

Hector.

I have a trigger which I can call after and before insert. I needs to warn or show a message to a user if record inserted fulfills the set of conditions.(I dont want to use addError). How can it be achieved? could not find reference as to how to show custom visual force page, thru pop or redirection(which ever works) .

 I have custom object having look up on lead, the column is Lead__c. I use javascript(ajax) to fetch the record "Select Lead__c From DSLeadDuplicate__c", similar logic for account and contact work with out any error.

 

The error message I get is

An error has occurred: {faultcode:'sf:INVALID_FIELD', faultstring:'INVALID_FIELD: Select Lead__c From DSLeadDuplicate__c ^ ERROR at Row:1:Column:8 No such column 'Lead__c' on entity 'DSLeadDuplicate__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.', detail:{InvalidFieldFault:{exceptionCode:'INVALID_FIELD', exceptionMessage:' Select Lead__c From DSLeadDuplicate__c ^ ERROR at Row:1:Column:8 No such column 'Lead__c' on entity 'DSLeadDuplicate__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.', row:'1', column:'8', }, }, }

 

Any help is appreciated

Hi,

 

I have made a trigger and inside that trigger, I need to access saved data value, for field name stored in a string variable.

e.g. Account myAccount = trigger.new[0];

String fieldName = 'Fax';

myAccount.Fax works;

myAccount.fieldName gives error.

 

 

 

 

trigger dsAccountTrigger on Account (after insert) {
Account myAccount = trigger.new[0];

String query = 'select FieldName__c,MatchType__c from FieldMatchTypeRules__c where ObjectName = \'account\'';
matches = Database.query(query);

for(integer i = 0; i < matches.size(); i++)
{
String matchType = matches[i].MatchType__c;
String myFieldScore = '';

myFieldScore = myAccount.Fax;//This works
//This does not work
myFieldScore = myAccount.matches[i].FieldName__c;
//How to access field value saved in variable?
}
}

 

Do I need to have a different approach.

 

Please guide

 

Regards

Hector...

Hi All,

 

I got the following error

Compile Error: Field is not writeable: Contact.Name at line 66.....

Following is the code snippet

 

 

global class clsCustomWebService_MergeStdObject {

...................

...............

webService static String mergeContactStdObj (String MasterId, String Slave1Id, String Slave2Id)
{


..........//This statement works

List<Account> ls = new List<Account>{new Account(name='Acme Inc.'),new Account(name='Acme')};
insert ls;


................................


...............//This line generate the error

List<Contact> ls = new List<Contact>{new Contact(name='Classic Inc.'),new Contact(name='Classic')};
insert ls;



......................

}

.........................

}

 

The same fails for Lead too.

What I want to achieve is run the code example as given in the below mentioned link for Account, Lead and Contact.

Following is the ref documentation link

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_merge.htm

 

 

 

Thanks

Hector....

 

Hello All,

 

I want to use the api merge() method in this class. I created a apex class and I got the following error for this statement:

MergeRequest mr = new MergeRequest();

 

Error: Compile Error: Invalid type: MergeRequest at line 7 column 33

 

If any one could point what am I doing wrong and what should be my approach, I want to call this webservice through flex.

 

My reference document is

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_merge.htm

 

 

global class clsWbSrv_MyService {

    webService static String fnMyService (String StdObjType, String MasterId, String Slave1Id, String Slave2Id) {
        String Result ='';
    Account masterAccount = new Account();

    MergeRequest mr = new MergeRequest();

      .................
      .................
      .................


       Result +=StdObjType + ' ' + MasterId + ' ' + Slave1Id + ' ' + Slave2Id;
        return Result;  
    }

}

 

 

Thanks

Hector....

 

HI,

This SOQL statement “Select Id, Title From ContentVersion”  will pull  all the records from the Salesforce CRM content.

Is there a way to pull records from a specified Workspace ?  I created 3 workspaces in CRM content and I only want to

pull records from certain workspaces using SOQL. Please help.

 

thanks,

Paul

 

  • March 05, 2010
  • Like
  • 0
We are lookin for a SF.com developer with 2-3 years experience, full time oppurtunity. Post resume

Need to set up partner portal with visual force page with custom search/filter functions to refine search on over 250K records. Also possiblity to set up recurring billing program for our clients.

 

Contact Scott Noftle

scottnoftle@gmail.com

 

 

I am looking for someone to put together a couple sign up pages for me.

 

Or point me in the right direction

We are looking for experienced Force.com developer, to assist our customer in developing an application on Force.com platform. The engagement will be 10 hours/week for about 4 to 6 months. Remote work is possible. Customer is based in Florida.

 

Consultant should be able to create a prototype, configure application, develop, test, and migrate the code.

 

Skills required:
- 2+ years development experience on the salesforce.com platform.

Preferred skills:
- Application development on the force.com platform.
- Apex Triggers.
- Visualforce pages.
- Security and Sharing model for the force.com platform / Apex.
- Customer portals with many users.
- Mash-up coding experience, related to the force.com platform.

 

Interested consultants, please send your resume with expected hourly rate to Careers@Vandesys.com

  • November 30, 2009
  • Like
  • 0
Hi,

I have a Trigger :

trigger UpdateSubTotalAndTotalTax on InventoryReceiptDetail__c (after insert, after update, after delete, after undelete, before update)
{
/* if(Trigger.isBefore && Trigger.isUpdate)
{
InventoryReceipt.UpdateReceivedCostInInventoryReceiptDetail(Trigger.new);
} */
if(Trigger.isDelete && Trigger.isAfter)
{
for(Integer i = 0; i < Trigger.old.size(); i++)
{
InventoryReceipt.UpdateSubTotalAndTotalTax(Trigger.old[i].ReceiptNo__c);
}
}
else if(Trigger.isInsert && Trigger.isAfter)
{
for(Integer i = 0; i < Trigger.new.size(); i++)
{
InventoryReceipt.UpdateSubTotalAndTotalTax(Trigger.new[i].ReceiptNo__c);
}
}
if(Trigger.isUpdate && Trigger.isAfter)
{
for(Integer i = 0; i < Trigger.new.size(); i++)
{
InventoryReceipt.UpdateInventoryStatusFromDetail(Trigger.new[i].ReceiptNo__c);
}
}
}

I dont know that how can i test this by writing Test method for this.

Please Help to solve this.

Thanks in advance

Shwetal Desai

The SELECT line fails....?

 

what am i doing wrong?

 

the error says: Invalid bind expression type of SOBJECT:Account for column of type String op regel 13 kolom 75 

 

 

trigger getRelatiecode on Opportunity (after insert) {

  System.debug('Making future call to sfservice');
  for (Opportunity opp : Trigger.New) {
    //Call future method to update account
    //with data from external server.
    //This is a async calls, it returns right away, after
    //enqueuing the request.

    string UID=UserInfo.getUserId();
    string UPW=UserInfo.getFirstName();
   
    string MK = [SELECT MarktSelect_Sleutel__c FROM Account WHERE Name = :opp.Account];
   
    integer MKR = integer.valueof(MK.MarktSelect_Sleutel__c);
   
    //SFservice.sFservice(opp.id, UID, UPW, MKR);
  }

}

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11">Hi,

when I am trying to upload the package, it is giving me following error.

Component Type    Name                    Problem
Apex Class             WebserviceCall    No testMethods found in the selected Apex code for the package

after writing some dummy test method it is giving error as only 0% test coverage, at least 75% test coverage require.
So is it compulsory to write test methods in apex classes?


Thanks..

 

I have SQL query here, can you help to transfer to SOQL?
 
Select o.OpportunityId from OpportunityLineItem o inner join PricebookEntry PE on o.PricebookEntryID=PE.ID inner join Product2 P on PE.product2ID=P.Id where P.Id in
(select Product2.Id from Product2 where Product2.Family  not LIKE 'Service%')
 
Thanks,
 
Cassie
  • September 11, 2008
  • Like
  • 0
Hello Friends,
 
I have developed my own custom webservice which integrates salesforce database with Oracle database at the backend.
 
I now want to deploy/host this webservice on Salesforce servers itself. I dont want to re-write it with APEX . I just want to deploy it on salesforce server instead of using any 3rd party server for hosting it.
 
Does Salesforce allows this? If yes, then how can i do this? By uploading the WSDL i am just able to call an external Webservice. But i want to deploy and then call it from salesforce itself.
 
I would be really grateful if anyone can give any pointers on this.
 
Thanks,
Cool_D
Hi Experts,
 
Though this question has already been asked by other, no definite answer has been made. Please help me.
 
To be straight, I have the following code:
 
Code:
<apex:page showHeader="false" controller="VehicleListControllerClass_2">
 <apex:form>
  <apex:pageBlock title="Vehicle List for {!personname}">
   <apex:pageBlockList value="{!vehicleList}" var="v">
    <apex:column value="{!v.VehicleName}"/>
    <apex:column value="{!v.PersonVehicle.Vehicle__r.Name}"/>
    <apex:column headerValue="Vehicle">
     <apex:outputLink value="/{!v.PersonVehicle.Vehicle__c}" target="_top">{!v.PersonVehicle.Vehicle__r.Name}</apex:outputLink>
    </apex:column>
    <apex:column>
     <apex:commandLink value="Click This Link" action="{!dosomething}" >
      <apex:param name="myparm" value="Link abcd"/>
     </apex:commandLink>
    </apex:column>
    <apex:column>
    <apex:commandButton value="Click This Button" action="{!dosomething}" styleClass="btn">
     <apex:param assignTo="{!MP}" name="myparm1" value="abcd"/>
     <apex:param name="myparm2" value="Button abcd"/>
    </apex:commandButton>
    </apex:column>
   </apex:pageBlockList>
  </apex:pageBlock>
 </apex:form>
</apex:page>


public class VehicleListControllerClass_2{

 public String getPersonName(){
  ID pId = System.currentPageReference().getParameters().get('id');
  String name = [Select Name from Person__c where id=:pId].Name;
  return name;
 }

 public class Vehicles{
  Person_Vehicle__c pv;
  //Constructor
  public Vehicles(Person_Vehicle__c pvin) {pv = pvin;}

  public Person_Vehicle__c getPersonVehicle() {return pv;}

  public String getVehicleName(){

   if(pv.Vehicle__r.Name == 'Maruti 800') return 'It is Maruti 800 yar';
   else return pv.Vehicle__r.Name;
  }

  Integer curYear = system.now().year();
  return (curYear - (Integer)pv.Purchase_Year__c);
  }
 }

 List<Vehicles> pvlist = new List<Vehicles>();

 public List<Vehicles> getVehicleList(){
  ID pId = System.currentPageReference().getParameters().get('id');

  pvlist.clear();
  for(Person_Vehicle__c pvv : [Select p.Person__r.Name, p.Vehicle__c,
  p.Vehicle__r.Name, p.Purchase_Year__c from Person_Vehicle__c p where p.Person__c=:pId]){
   pvlist.add(new Vehicles(pvv));
  }

  return pvlist;
 }

 String p;
 public String getMP(){
  return p;
 }

 public void setMP(String s){
  p=s;
 }
 
 public PageReference dosomething(){
  String s = System.CurrentPageReference().getParameters().get('myparm');
  String s1 = System.CurrentPageReference().getParameters().get('myparm1');
  String s2 = System.CurrentPageReference().getParameters().get('myparm2');
  System.debug(s);
  System.debug(s1);
  System.debug(s2);
  return null;
 }

}

When I click on the link 'Click This Link', String 's' returns 'Link abcd' which is correct.
 
But when I click on the link 'Click This Button', both Strings 's1' and 's2' returns null.
 
How could I get the param value in controller in case of 'commandButton'?
Please note that I Must use commandButton and I need to pass more than one parameters.
 
Also, I would like to be able to create a new Case (in another visualforce page) with few default values by clicking a commandButton. The page should open as if user clicked on 'New' button and ready to Save. Please note that the page will not be associated with 'Case' controller.
 
How could I achieve this functionality?
 
Thanks,
-Roshan
Hi,

I want to create a Task after saving a customer Object.
In my Customer Object I give a User FIeld: Editor.
I try with this Code

Code:
task.WhatId = Object.id;
task.WhoId = Object.Editor__c;
task.Subject = 'Other';
task.priority= Object.Priority__c;
task.status = 'Not Started';
task.description = 'New  Work';
insert task;

 And I become this failure:

Attempt to de-reference a null object

Do you have an Idea to help me?

Thx

Magda




Message Edited by magda on 02-13-2008 12:32 AM
  • February 08, 2008
  • Like
  • 0
Hi,

I have a 'before insert trigger' on Opportunity. The trigger contains an SOQL select query which returns(may or may not) one record and assigns to an Opportunity variable.
The query statement is:
"Opportunity Opp_variable = [SELECT id,Counter__c,AccountId FROM Opportunity where (AccountId=:New_record.AccountId AND Counter__c!=null) ORDER BY Counter__c DESC LIMIT 1];"

After this statement I have "if(Opp_variable!=NULL)..statements",
But I get the Error message:
"System.QueryException: List has no rows for assignment to SObject"
This is caused because there is no record satisfying my query conditions.. But it should have returned NULL.. ?

Why Am I getting this error..!! SOQL query cannot return null value??

How can I sove this issue..? Please help me

Thanks in Advance..
Krishna