• msreekm
  • NEWBIE
  • 5 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 11
    Replies

I get this error when running install.sh.

 

iOSShared.compile:
[echo] installing SBJson for SDK iphoneos
[exec] Error: No developer directory found at /Applications/Xcode.app/Contents/Developer. Run /usr/bin/xcode-select to update the developer directory path.

 

I dont see DEveloper folder in my xcode installation path. (Xcode 4.3) . 

When you create a case from email using Outlook connector it creates an activity (task). Whcih makes it tough for the users to see the email unless they look in both email and activity histry related lists.

I found a solution to write a trigger on task object and create an entry in email message.   Are there any other solutions?

 

thanks

sree

Using the new "My Domain "  feature in spring 10 can we solve the javascript cross domain issues? 

 

As per the documentation 

Personalize your salesforce.com URL  - Get a personalized, easy-to-remember saleforce.com URL Provide additional security to your organization.

 

Q: Will the apex code also run on the same domain (which otherwise runs in the force.com domain) there by solving the cross domain javascript issues faced now within an iframe.

 

Thanks

Sree

 

User A is inserting a lead ,which executes LeadsTrigger . LeadsTrigger get all leads with the following code-  "select id from leads".  Q:Will this soql get all the leads  or only the leads below User A's role heirarchy. Also can UserA update a lead belonging to UserB (owner).

 

If this is the case  how do we have a logic that will check against all lead records (for eg. de-duping)

 

Thanks,

Sree

 

public with sharing class MyTest {
   static string mynum='10';
    private MyTest()    {
       mynum='11112222';
    }      
 static testMethod void testMethod1() {
   System.Debug('value of mynum >>>>>>>' + MyTest.mynum);  -- prints 10
    } 
 static testMethod void testMethod2() {           
       mynum='1111';
       System.Debug('value of mynum  >>>>>>>' + MyTest.mynum);  --prints  1111
  }
}

 

I observed that test method 2 execute first and then test method 1. Is there a good way to init common data across methods. MyTest() constructor doesnt work . Also value set in one method is not retained in the next method..

In my afterinsert trigger  on Lead , I want to update one of the fields in the current Lead records being inserted .I cannot do this in before insert since Iam dependent on the ID's of the newly inserted leads .

 

Getting the below error-

 

LeadTrigger: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id 00QT0000005JQ05MAG;

first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []

 

any one encountered this issue?

how do we compare phone in lead/account objects in soql where phone in ('111-222-3334','111-222-3335') ..

 

salesforce  stores phone numbers in various fomrats like (xxx) xxx-xxxx , xxx-xxx-xxxx,xxxxxxxxx . Is there an efficient way to compare across all these formats?

 

one poss soln - create a new field and store all phone numbers in same format -eg. xxxxxxxxxx.

 

 

test.startTest();

  insert leads;

test.stopTest();

 

lead2.Phone = '510-366-1003';

lead3.Phone = '510-366-1004';

test.startTest(); --> Error here

   update leads;

test.stopTest();

 

I get the above error- Testing already started!@

Message Edited by msreekm on 10-25-2009 05:36 PM

How do we check duplicates for multiple fields in leads. (email address ,company and phone)

 

leadDuplicatePreventer trigger (below) in the cookbook has the code for checking duplicate in email address. but what is the best way to  add more fields..

 

trigger leadDuplicatePreventer on Lead (before insert, before update) {

Map<String, Lead> leadMap = new Map<String, Lead>();

for (Lead lead : System.Trigger.new) {

if ((lead.Email != null) &&

    (System.Trigger.isInsert || (lead.Email != System.Trigger.oldMap.get(lead.Id).Email))) {

if (leadMap.containsKey(lead.Email)) {

  lead.Email.addError('Another new lead has the ' + 'same email address.');

} else { 

    leadMap.put(lead.Email, lead); 

}

}

}

for (Lead lead : [SELECT Email FROM Lead WHERE Email IN :leadMap.KeySet()]) {

Lead newLead = leadMap.get(lead.Email);

newLead.Email.addError('A lead with this email ' + 'address already exists.');

}

}

Using the new "My Domain "  feature in spring 10 can we solve the javascript cross domain issues? 

 

As per the documentation 

Personalize your salesforce.com URL  - Get a personalized, easy-to-remember saleforce.com URL Provide additional security to your organization.

 

Q: Will the apex code also run on the same domain (which otherwise runs in the force.com domain) there by solving the cross domain javascript issues faced now within an iframe.

 

Thanks

Sree

 

:smileysad::smileysad:

 

Hi All,

 

I have a urgent issue to be resolved. I have migrated my code into the production environment.

The code moved successfully in to the production area. But an issue arised on executing the piece of code in production.

 

I have written a batchable class to avoid governer limits, using the queryLoacator. Even then the issue isn't resolved.

 

Please enlighten me why such issues arise and provide some information on governor limits and how one could bypass them when bulk data query is required.

 

Please find my piece of code below.

global class Get_Account_Id_EPC implements Database.Batchable<sObject>
{
    Public String Query;

    Global  database.querylocator start(Database.BatchableContext BC){
        Return database.getquerylocator(query);
    }

    Global void execute(Database.BatchableContext BC, List<SObject> scope)
    {
        List<Express_Payment__c> updatelist = new List<Express_Payment__c>();
        List<Express_Payment__c> epsobj = [Select  id,Agent__c,BP_ID__c,BP_Loc_Id__c from Express_Payment__c limit 1000];

        for(Express_Payment__c records : epsobj){
            for(sObject s : scope){
                Account a = (Account)s;
                if(records.BP_ID__c!=null && records.BP_loc_ID__c!=null&&records.BP_ID__c == a.BPID__c && records.BP_Loc_Id__c == a.BP_Loc_Id__c){
                    records.Agent__c = a.id;
                    updatelist.add(records);
                    break;
                }
            }
        }
        update(updatelist);
        
        List<Utility_Bill_Payment__c> updatelist1 = new List<Utility_Bill_Payment__c>();
        List<Utility_Bill_Payment__c> ubpobj = [Select  id,Agent__c,BP_ID__c,BP_Loc_Id__c from Utility_Bill_Payment__c limit 1000];

        for(Utility_Bill_Payment__c records : ubpobj){
            for(sObject s : scope){
                Account b = (Account)s;
                if(records.BP_ID__c!=null && records.BP_loc_ID__c!=null&&records.BP_ID__c == b.BPID__c && records.BP_Loc_Id__c == b.BP_Loc_Id__c){
                    records.Agent__c = b.id;
                    updatelist1.add(records);
                    break;
                }
            }
        }
        update(updatelist1);
        
        List<PrePaid_Card__c> updatelist2 = new List<PrePaid_Card__c>();
        List<PrePaid_Card__c> ppcobj = [Select  id,Agent__c,BP_ID__c,BP_Loc_Id__c from PrePaid_Card__c limit 1000];

        for(PrePaid_Card__c records : ppcobj){
            for(sObject s : scope){
                Account c = (Account)s;
                if(records.BP_ID__c!=null && records.BP_loc_ID__c!=null&&records.BP_ID__c == c.BPID__c && records.BP_Loc_Id__c == c.BP_Loc_Id__c){
                    records.Agent__c = c.id;
                    updatelist2.add(records);
                    break;
                }
            }
        }
        update(updatelist2);
        
        List<MT_Volume_Reports__c> updatelist3 = new List<MT_Volume_Reports__c>();
        List<MT_Volume_Reports__c> mtannualobj = [Select  id,Agent__c,BPID__c,BP_Loc_Id__c from MT_Volume_Reports__c limit 1000];

        for(MT_Volume_Reports__c records : mtannualobj){
            for(sObject s : scope){
                Account d = (Account)s;
                if(records.BPID__c!=null && records.BP_loc_ID__c!=null&&records.BPID__c == d.BPID__c && records.BP_Loc_Id__c == d.BP_Loc_Id__c){
                    records.Agent__c = d.id;
                    updatelist3.add(records);
                    break;
                }
            }
        }
        update(updatelist3);
        
        List<MT_Volume__c> updatelist4 = new List<MT_Volume__c>();
        List<MT_Volume__c> mtobj = [Select  id,Agent__c,BPID__c,BP_Loc_Id__c from MT_Volume__c limit 1000];

        for(MT_Volume__c records : mtobj){
            for(sObject s : scope){
                Account e = (Account)s;
                if(records.BPID__c!=null && records.BP_loc_ID__c!=null&&records.BPID__c == e.BPID__c && records.BP_Loc_Id__c == e.BP_Loc_Id__c){
                    records.Agent__c = e.id;
                    updatelist4.add(records);
                    break;
                }
            }
        }
        update(updatelist4);
        
        List<MO_Volume__c> updatelist5 = new List<MO_Volume__c>();
        List<MO_Volume__c> moobj = [Select  id,Agent__c,BP_ID__c,BP_Loc_Id__c from MO_Volume__c limit 1000];
        for(MO_Volume__c records : moobj){
            for(sObject s : scope){
                Account f = (Account)s;
                if(records.BP_ID__c!=null && records.BP_loc_ID__c!=null&&records.BP_ID__c == f.BPID__c && records.BP_Loc_Id__c == f.BP_Loc_Id__c){
                    records.Agent__c = f.id;
                    updatelist5.add(records);
                    break;
                }
            }
        }
        update(updatelist5);
    }

    Global void finish(Database.BatchableContext info){
    }

    /* Test Coverage Class*/
    Public static testMethod void SEUpdateTest()
    {
        User currentUser = [Select u.Id From User u Where u.Id =: UserInfo.getUserID()];
        List<Account> testAccs = new List<Account>();
        for(integer i=0;i<10;i++)
        {
            Account testAccount = new Account(Name = 'TestAccount'+i, OwnerId = currentUser.Id);
            testAccs.add(testAccount);
        }
        insert testAccs;
        Test.starttest();
        Get_Account_Id_EPC sObj = new Get_Account_Id_EPC();
        sObj.Query = 'Select id,BPID__c,BP_Loc_Id__c from Account';
        ID BatchId = Database.executeBatch(sObj,500);
        test.stoptest();
        AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email from AsyncApexJob where Id = :BatchId];
        System.debug('\n\nFinal results are: '+a);
        //System.AssertEquals('Completed', a.status);
        //System.AssertEquals(0, a.NumberOfErrors);
    }

}

 

Above is my batchable class.

 

Using below code i invoke the batchable class :

    public void exec6(){
        Get_Account_Id_EPC epcQuery = new Get_Account_Id_EPC();
        epcQuery.Query = 'Select id,BPID__c,BP_Loc_Id__c from Account';
        ID batchprocessid = Database.executeBatch(epcQuery);
   }

 

The issue arises when i tr to execute the code in production giving out an error System.LimitException: Too many script statements: 1000001, Pointing to the following line:

 

if(records.BP_ID__c!=null && records.BP_loc_ID__c!=null&&records.BP_ID__c == f.BPID__c && records.BP_Loc_Id__c == f.BP_Loc_Id__c)

 

I am failing to understand why this error is occuring. Please help me with the same.

 

I am running out of time :(

Any pointers are appreciated.

 

- TIA

 

Sushupsi 

I've tried to upload a trigger to sandbox via Eclipse but I get an error stating that the ORG is not enabled for deploying, I also get an error INVALID_TYPE: Cannot create ApexClass. So basically i CAN'T SAVE ANY CHANGES TO SANDBOX.

I've tried all sort of things such as changing the XML to Active ut it won't save the changes to sandbox. I dont know why it is doing this, since I've done all sort of triggers and some coding and never saw this issue in Sandbox, only in production.

 

Can anyone tell me what it is that I am not noticing or need to do?

 

This is the error I get when I try to save the trigger to Sandbox:

 

 

Description Resource Path Location Type
Save error: Not available for deploy for this organization PreventPortalUserOwner2.trigger _SANDBOX Shell Project/src/triggers line 0 Force.com save problem

Description Resource Path Location TypeSave error: Not available for deploy for this organization

 

 

 

 

"The new Force.com IDE for Spring '10 will be released on April 19th"

 

Okay, it's April 19th now.  Give me, give me!

 

Force.com IDE 3.5.x

In my afterinsert trigger  on Lead , I want to update one of the fields in the current Lead records being inserted .I cannot do this in before insert since Iam dependent on the ID's of the newly inserted leads .

 

Getting the below error-

 

LeadTrigger: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id 00QT0000005JQ05MAG;

first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []

 

any one encountered this issue?

Hi,

 

I have Eclipse 3.4.2 with Force.com IDE plugin installed. The issue is that the suggestion box (that displays all methods and members accessible for an object -default hotkey is Ctrl-Space) works on and off; sometimes it works sometimes it doesn't. And it doesn't work exactly when I need it the most. Is there anything to fix this?

 

Thanks.

  • October 29, 2009
  • Like
  • 0

When developing a Visualforce page for overiding view page for any object, one problem that creeps up is to display the History details of a record. The standard related list Component doesn't works for History.

 

With the help of some code from Community ( I now can't find the link to it :( ), I wrote my own code  then to display the history of an object. It mimics the standard list as far as possible.  

 

Heres the code. It is for the Case object but it can be used for any other object.

 1.Component Code

 

<apex:component controller="CaseHistoriesComponentController">
<!-- Attribute Definition -->
<apex:attribute name="CaseId" description="Salesforce Id of the Case whose Case History needs to be rendered" type="Id" required="true" assignTo="{!caseId}" />

<!-- Case History Related List -->
<apex:pageBlock title="Case History">
<apex:pageBlockTable value="{!histories}" var="History" >
<apex:column headerValue="Date" value="{!History.thedate}"/>
<apex:column headerValue="User"> <apex:outputLink value="/{!History.userId}"> {!History.who} </apex:outputLink></apex:column>
<apex:column headerValue="Action"><apex:outputText escape="false" value="{!History.action}"/></apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:component>

 

 

 

 

2. Apex Code

 

public class CaseHistoriesComponentController {

public Id caseId {get; set;}
public cHistories[] histories;

// Variables
public Static final Map<String, Schema.SObjectField> CaseFieldmap = Schema.SObjectType.Case.fields.getMap();
public Static final List<Schema.PicklistEntry> fieldPicklistValues = CaseHistory.Field.getDescribe().getPicklistValues();

public List<cHistories> getHistories()
{
list<cHistories> histories = new list<cHistories>();
String prevDate = '';
for(CaseHistory cHistory : [Select CreatedDate, CreatedBy.Name, CreatedBy.Id, Field, NewValue, OldValue from CaseHistory where CaseId = :caseId order by CreatedDate desc])
{
if((cHistory.newValue == null && cHistory.oldValue == null)
|| (cHistory.newValue != null && !(string.valueOf(cHistory.newValue).startsWith('005') || string.valueOf(cHistory.newValue).startsWith('00G')))
|| (cHistory.oldValue != null && !(string.valueOf(cHistory.oldValue).startsWith('005') || string.valueOf(cHistory.oldValue).startsWith('00G'))))
{
cHistories tempHistory = new cHistories();
// Set the Date and who performed the action
if(String.valueOf(cHistory.CreatedDate) != prevDate)
{
tempHistory.theDate = String.valueOf(cHistory.CreatedDate);
tempHistory.who = cHistory.CreatedBy.Name;
tempHistory.userId = cHistory.CreatedBy.Id;
}
else
{
tempHistory.theDate = '';
tempHistory.who = '';
tempHistory.userId = cHistory.CreatedBy.Id;
}
prevDate = String.valueOf(cHistory.CreatedDate);

// Get the field label
String fieldLabel = CaseHistoriesComponentController.returnFieldLabel(String.valueOf(cHistory.Field));

// Set the Action value
if (String.valueOf(cHistory.Field) == 'created') { // on Creation
tempHistory.action = 'Created.';
}
else if(cHistory.OldValue != null && cHistory.NewValue == null){ // when deleting a value from a field
// Format the Date and if there's an error, catch it and re
try {
tempHistory.action = 'Deleted ' + Date.valueOf(cHistory.OldValue).format() + ' in <b>' + fieldLabel + '</b>.';
} catch (Exception e){
tempHistory.action = 'Deleted ' + String.valueOf(cHistory.OldValue) + ' in <b>' + fieldLabel + '</b>.';
}
}
else{ // all other scenarios
String fromText = '';
if (cHistory.OldValue != null) {
try {
fromText = ' from ' + Date.valueOf(cHistory.OldValue).format();
} catch (Exception e) {
fromText = ' from ' + String.valueOf(cHistory.OldValue);
}
}

String toText = '';
if (cHistory.OldValue != null) {
try {
toText = Date.valueOf(cHistory.NewValue).format();
} catch (Exception e) {
toText = String.valueOf(cHistory.NewValue);
}
}
if(toText != '')
tempHistory.action = 'Changed <b>' + fieldLabel + '</b>' + fromText + ' to <b>' + toText + '</b>.';
else
tempHistory.action = 'Changed <b>' + fieldLabel;
}

// Add to the list
histories.add(tempHistory);
}
}

return histories;
}

// Function to return Field Label of a Case field given a Field API name
public Static String returnFieldLabel(String fieldName)
{
if(CaseHistoriesComponentController.CaseFieldmap.containsKey(fieldName))
return CaseHistoriesComponentController.CaseFieldmap.get(fieldName).getDescribe().getLabel();
else
{
for(Schema.PicklistEntry pickList : fieldPicklistValues)
{
if(pickList.getValue() == fieldName)
{
if(pickList.getLabel() != null)
return pickList.getLabel();
else
return pickList.getValue();
}
}
}
return '';
}
// Inner Class to store the detail of the case histories
public class cHistories {

public String theDate {get; set;}
public String who {get; set;}
public Id userId {get; set;}
public String action {get; set;}
}
}

  Let me know your views on the code or if you have any questions

 

How do we check duplicates for multiple fields in leads. (email address ,company and phone)

 

leadDuplicatePreventer trigger (below) in the cookbook has the code for checking duplicate in email address. but what is the best way to  add more fields..

 

trigger leadDuplicatePreventer on Lead (before insert, before update) {

Map<String, Lead> leadMap = new Map<String, Lead>();

for (Lead lead : System.Trigger.new) {

if ((lead.Email != null) &&

    (System.Trigger.isInsert || (lead.Email != System.Trigger.oldMap.get(lead.Id).Email))) {

if (leadMap.containsKey(lead.Email)) {

  lead.Email.addError('Another new lead has the ' + 'same email address.');

} else { 

    leadMap.put(lead.Email, lead); 

}

}

}

for (Lead lead : [SELECT Email FROM Lead WHERE Email IN :leadMap.KeySet()]) {

Lead newLead = leadMap.get(lead.Email);

newLead.Email.addError('A lead with this email ' + 'address already exists.');

}

}

Does anyone know the max length in characters an Apex trigger can be? I get a message about my trigger being too long, but the limit is not provided.

 

Thanks!

I'm trying to test the sample provided on p. 118-119 of the Cookbook to prevent duplicate leads based on email address. I have come across two errors so far in the trigger:
 

Error: Compile Error: expecting a right parentheses, found 'get' at line 10 column 1

 

I seem to be able to get past this error by removing "get"

 

Error: Compile Error: Method does not exist or incorrect signature: [MAP:Id,SOBJECT:Lead].(Id) at line 9 column 16

I am not sure I know what is causing this error or how to fix. Any thoughts??

 

Here is the trigger from the cookbook:

 

trigger leadDuplicatePreventer on Lead (before insert, before update) {

Map<String, Lead> leadMap=new Map<String, Lead>();

for (Lead lead : System.Trigger.New) {

 

//make sure we don't treat an email address that

// isn't changing during an update as a duplicate.

if ((lead.Email !=null) &&

(System.Trigger.isInsert ||

(lead.Email != System.Trigger.oldMap.

get(lead.Id).Email))) {

 

//make sure another new lead isn't also a duplicate

if (leadMap.containsKey(lead.Email)) {

lead.Email.addError('Another new lead has the '

+'same email address.');

}else {

leadMap.put(lead.Email, lead);

}

}

}

 

//Using a single database query, find all the leads in

//the database that have the same email address as any

// of the leads being inserted or updated.

for (Lead lead : [SELECT email FROM Lead

WHERE Email IN :leadMap.KeySet ()]) {

Lead newLead=leadMap.get(lead.Email);

newLead.Email.addError('A lead with this email '

+ 'address already exists.');

}

}

 

 

 

  • May 20, 2008
  • Like
  • 0