• MJ Kahn / OpFocus
  • NEWBIE
  • 450 Points
  • Member since 2012
  • VP Development & Product Strategy

  • Chatter
    Feed
  • 14
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 101
    Replies
Hello All,

I have created a VisualForce page with a list that allows the end user to enter the values into the fields all at once.  At the end of each row, they have an option to add another row or to save all the data.  

In standard view, I have a verification rule on one of the Field X that makes sure if Field Y equals a specific value, then Field X cannot be Null.  This works great in the Standard view; however throws an exception error when entering through the VF list.  

I am not sure how to write a code for the VF list that verifies that Field X is not Null when Field Y equals a specific value.  Moreover, I have my list listNewTime and I do not know how to access the data temporarily being stored there prior to running the insert command.  

Thank you in advance. 
I am attempting to match up users coming in from an external POST request to Salesforce users via a SOQL query of the name that returns a user record, then use the ID from the user record to insert a custom object record with a User Lookup field. However I am getting the following error: 
Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, User: id value of incorrect type: 005U0000003GvJKIA0: [User__c]
This error is being thrown because the ID needs to be 15 characters, but is, in practice, coming out as 18 characters. I have tried a few different methods of limiting the string to 15 chars, but to no avail. This is frustrating because it works just fine in the sandbox environment, it is only when deployed to production that this error comes up.

Methods I have tried:

1. No string correction
// match names list to users and create records for each user
        finalCount = names.size();
        for (Integer j = 0; j < finalCount; j++) {
        
            User matchUsr = [SELECT Id, Name
                                FROM User
                                WHERE Name = :names[j]
                                LIMIT 1];
            String usrId = matchUsr.Id;
            
            indivs.add(new Late_Tasks_by_User__c(User__c=usrId,Dependent_Tasks__c=deps[j],Actual_Late_Tasks__c=lates[j],Date__c=datej));
            usrId = '';
            echoOut += names[j] + ', ';
        }

2. Substring the usrId string to (0,15) 
// match names list to users and create records for each user
        finalCount = names.size();
        for (Integer j = 0; j < finalCount; j++) {
        
            User matchUsr = [SELECT Id, Name
                                FROM User
                                WHERE Name = :names[j]
                                LIMIT 1];
            String userMatch = matchUsr.Id;
            String usrId = userMatch.subString(0, 15);
            
            indivs.add(new Late_Tasks_by_User__c(User__c=usrId,Dependent_Tasks__c=deps[j],Actual_Late_Tasks__c=lates[j],Date__c=datej));
            usrId = '';
            echoOut += names[j] + ', ';
        }

3. Take one character from the ID string of the user record at a time (0-14), and add to new usrId string
// match names list to users and create records for each user
        finalCount = names.size();
        for (Integer j = 0; j < finalCount; j++) {
        
            User matchUsr = [SELECT Id, Name
                                FROM User
                                WHERE Name = :names[j]
                                LIMIT 1];
            String userMatch = matchUsr.Id;
            String usrId = '';
            for (Integer xc = 0; xc < 15; xc++) {        
                usrId += userMatch.subString(xc, xc+1);
            }
            
            indivs.add(new Late_Tasks_by_User__c(User__c=usrId,Dependent_Tasks__c=deps[j],Actual_Late_Tasks__c=lates[j],Date__c=datej));
            usrId = '';
            echoOut += names[j] + ', ';
        }

None of these have produced a working result. All three continue to return an 18 character string as the usrId variable. I have found several threads on this forum regarding this topic, but the only solutions that are listed with those questions are either syntax error with the specific code, or someone saying that you have to subString the ID. If anyone has any solutions or ideas beyond that, please let me know.

Thanks,
Joe
I have a SelectList which contains a list of user actions (replaces the need for multiple buttons). I have successfully implemented AcionSupport to invoke an Apex call, but I want to issue a "confirm" dialog on 2 of the actions in the list. My JS skills are very primitive, so I suspect this is not really a difficult task.

Here is my VF code excerpt:

<apex:selectList id="nextAction" value="{!nextAction}" size="1" 
Title="Select the next action">
<apex:selectOptions value="{!nextActionList}"></apex:selectOptions>                        
<apex:actionSupport event="onchange" action="{!doNextAction}" /> 
</apex:selectList>


I want to put an "onchange" event on the selectList which passes the selected option to a JS script which checks the action and optionally displays a confirm warning.

Any help greatly appreciated

 
Well I created a Public Class/Controller, then I couldn't find it (wasn't coming up in any search), so I tried and recreating it, but it says it's already created.  What gives?  This is very bizarre behavior.  
can anyone please tell me if itsw mandatory to deploy test class in production?
Hey everyone,

I wrote a trigger that's not getting any errors, but it's simply not working. Here is what I'm trying to do:

-We created a multi-select picklist on Opportunities called 'Opportunity Industries'
-We did this because if the account is an Agency, then the opp may have multiple industries
-But if the account is not an Agency? We simply want the Opportunity Industries field to be populated with the account's industry

Here is the trigger I wrote, which is not getting errors, but it's not updating the Opportunity Industries field:


trigger OppIndustry on Opportunity (before insert, before update) {
   
    Set<String> relevantAccountIds = new Set<String>();
     for (Opportunity o : Trigger.new) {
            IF(o.Account.Industry != NULL){
            relevantAccountIds.add(o.AccountId);
            }
        }
   
    List<account> accountsWithIndustry = [SELECT Id, Industry FROM Account WHERE Id IN :relevantAccountIds];
   
    map<string,string> accountsMap = new map<string,string>();
     for(Account a : accountsWithIndustry) {
        accountsMap.put(a.Id,a.Industry);
        }
   
    for(Opportunity oppInTrigger : Trigger.new) {
        IF(oppInTrigger.Account.Industry != NULL && oppInTrigger.Account.Industry != 'Agency') {
            String oppAccountIndustry = accountsMap.get(oppInTrigger.AccountId);
            oppInTrigger.Opportunity_Industries__c = oppAccountIndustry;
        }
    }
}



Any idea why that might not be working? I tried adding and removing the IF statement in the first 'for' statement, but that didn't do anything. I also tried changing the map to an 'account,string' map (and making the other necessary changes throughout the trigger accordingly), but that didn't help either.

Anything else I should try?

Thanks!
-Greg

I have a class I wrote to automatically create Assets when a Case is closed based on values within the Case.

I also have a test class that I thought would test each instance but for some reason, though the test passes, though the code functions as desired, the testing states 0/0 test methods passed and 0% code coverage.  What have I overlooked?

Note, string values listed may not match as I've tried to strip company specific information from the code.

 

public class CreateAsset 
{
    public static void newAsset(Case[] cs)
    {
        // declare variables
        string dtmToday = system.today().format();
        string strDesc = '' ;   /* see other workbook */
        string strType = ''; 
        id strOwnr = null;      /* depends on product */ 

        for (Case c:cs)
        {  
        if (c.isclosed == true){
            if (c.Asset_Created__c != true)
            {
                id strAcct=null; 

                string strName = c.asset_to_install__c + ' - ' + c.client_id__c + ' - ' + dtmToday;
                strAcct = c.accountid; 
                id strCont = c.contactid; 
                id strCase = c.id; 
                id strOpp  = c.opportunity__c; 

                /* Check Reason Detail for Description and Type value */
                strType = 'New'; 
                if (c.Reason_Detail__c == 'New - Prod 1')
                {
                    strDesc = 'New sale as a consolidator'; 
                }
                if (c.Reason_Detail__c== 'New - Prod 2')
                {
                    strDesc = 'New sale'; 
                }
                if (c.Reason_Detail__c== 'New - Prod 3')
                {
                    strDesc = 'New sale'; 
                }
                if (c.Reason_Detail__c== 'New - Prod 4' || c.Reason_Detail__c == 'New - Prod 5')
                {
                    strDesc = 'New sale'; 
                }
                if (c.Reason_Detail__c== 'a reason detail')
                {
                    strDesc = 'a description'; 
                    strType = 'Migration'; 
                }
                if (c.Reason_Detail__c== 'Because')
                {
                    strDesc = 'a description'; 
                    strType = 'Migration'; 
                }
                if (c.Reason_Detail__c== 'New - Prod 6')
                {
                    strDesc = 'New sale'; 
                }
                if (c.Reason_Detail__c== 'New - Prod 7')
                {
                    strDesc = 'something'; 
                    strType = 'New'; 
                }

                /* Check Product Group for assignment                                       */ 
                /* Owned by JDoe unless one of the following is true  */ 
                /* JDoe= 00570000001fNiX                                                 */
                /* CDoe= 00570000001hbu7                                             */
                /* FDoe=   00570000001aSmE                                             */ 

                strOwnr = '00570000001fNiX'; 
                If (c.Product_Group__c == 'Prod' || c.Product_Group__c == 'Prod')
                {
                    strOwnr = '00570000001hbu7'; 
                }
                If (c.Product_Group__c == 'Prod')
                {
                    strOwnr = '00570000001aSmE';
                }
                if (strDesc != '')
                {
                    Asset[] newAsset = new Asset[0]; 

                    newAsset.add(new Asset(
                    Name = strName, 
                    AccountId = strAcct, 
                    ContactId = strCont,  
                    Owner__c = strOwnr, 
                    Case_Number__c = strCase, 
                    Opportunity__c = strOpp, 
                    Description = strDesc, 
                    Requestor__c = c.Requestor__c , 
                    Type__c = strType, 
                    Status = 'Purchased', 
                    Quantity = 1, 
                    PurchaseDate = c.Contract_Signature_Date__c, 
                    Medium__c = c.Media__c, 
                    
                    Number_of_Users__c = c.No_of_Users__c, 
                    Product_Group__c = c.Product_Group__c));
                    
            if (c.Asset_Created__c != true){
              if (c.isclosed == true) {
                    insert newAsset;
              }
            }
                    
           // update the existing case
                    c.AssetId=newAsset[0].id;            
                    c.Asset_Created__c=true; 
                    c.Asset_Created_dt__c=system.today();
              //      update c;
                }
            }
            }
        }
    }
}

 And here's the test

@isTest(SeeAllData=true)
private class CreateAssetTest{
    static void testAll(){
        TestObjects to = new TestObjects();
    Account acct = to.getAccount(true);
        Contact contact = to.getContact(acct.Id, false);
        Date theDate=System.today();
        // Create test cases
        List<Case> cases = new List<Case>{};
            for(Integer i = 0; i < 8; i++){
                Case c = new Case(Subject='Test Case ' + i, 
                                 AccountId=acct.Id, 
                                 ContactId=contact.Id, 
                                 Requestor__c=contact.Id, 
                                 Origin='Self-initiated', 
                                 Description='Test Case ' + i,  
                                 Contract_Signature_Date__c=theDate, 
                                 Media__c='DVD', 
                                 No_of_Users__c=2, 
                                 Product_Group__c='', 
                                 Reason__c='',
                                 Reason_Detail__c='',
                                 Status='Open'); 
                cases.add(c);
                
                for(i = 0; i < 8; i++){
                    cases[i].status='Closed';
                    if(i==0){ 
                        cases[i].Reason__c='New Account Setup';
                        cases[i].Reason_Detail__c='New - Prod 1'; 
                        cases[i].Product_Group__c='Group';
                    }
                    if(i==1){
                        cases[i].Reason__c='New Account Setup';
                        cases[i].Reason_Detail__c='New - Prod 2';
                        cases[i].Product_Group__c='Group';
                    }
                    if(i==2){
                        cases[i].Reason__c='New Account Setup';
                        cases[i].Reason_Detail__c='New - Prod 3';
                        cases[i].Product_Group__c='Group';
                    }
                    if(i==3){
                        cases[i].Reason__c='New Account Setup';
                        cases[i].Reason_Detail__c='New - Prod 4';
                        cases[i].Product_Group__c='Group';
                    }
                    if(i==4){
                        cases[i].Reason__c='Acct Maintenance';
                        cases[i].Reason_Detail__c='Maintenance - Media Change';
                        cases[i].Product_Group__c='Group';
                    }
                    if(i==5){
                        cases[i].Reason__c='ABS/ABL';
                        cases[i].Reason_Detail__c='ABS/ABL - Migration';
                        cases[i].Product_Group__c='Group';
                    }
                    if(i==6){
                        cases[i].Reason__c='New Account Setup';
                        cases[i].Reason_Detail__c='New - Prod 5';
                        cases[i].Product_Group__c = 'Group';
                    }
                    if(i==7){
                        cases[i].Reason__c='New Account Setup';
                        cases[i].Reason_Detail__c='New - Prod 6';
                        cases[i].Product_Group__c = 'Group';
                    }
                }
                update cases;
                CreateAsset.newAsset(cases);
            }
  }
}

 

Hi ,

 

I want to write a program for forgot password button .

 

it has to work in the following way -> 

 

once i click the button , the user has to give his email id 

if the email id is present in my database i have a shoot his password to his email id ... 

 

 

please help ... 

Ahhh what fun writing unit tests for the REST API, there seems to be quite a few posts about this and I'm afraid I'm going to add another.

 

I have an Apex REST class that uses a custom class called SAPAccount to hold the details of a JSON message I'm receiving.

 

global static SAPAccount[] doPost( SAPAccount[] sapsoldtos ){
... logic here...
}

 

When I try and call this method in my test class I get the error message "Illegal assignment from LIST<SAPAccountREST.SAPAccount> to SAPAccountREST.SAPAccount".

 

In the test class I'm creating a list of SAPAccounts and then adding to that list.

 

List<SAPAccountREST.SAPAccount> sapAcctList = new List<SAPAccountREST.SAPAccount>();
String jsonMsg = '';

SAPAccountREST.SAPAccount jsonSapAcct = new SAPAccountREST.SAPAccount();
jsonSapAcct.E1KNA1M_KUNNR = '0000000001';
jsonSapAcct.E1KNA1M_NAME = 'Customer Name';
jsonSapAcct.E1KNA1M_STRAS = 'Street';
jsonSapAcct.E1KNA1M_ORT01 = 'Town';
jsonSapAcct.E1KNA1M_PSTLZ = 'Postal Code';
jsonSapAcct.E1KNA1M_LAND1 = 'Country';
jsonSapAcct.E1KNA1M_STCEG = 'Vat';
		
sapAcctList.add( jsonSapAcct );
jsonMsg = JSON.serialize( jsonSapAcct );

 

I then try and call the Apex method using the following code which is when of course the error occurs:

 

SAPAccountREST.SAPAccount results = SAPAccountREST.doPost( sapAcctList );

 

Would greatly appreciate any help that anyone could provide.

I created one custom button on Opportunity. By clicking that button have to open VF page for that page want to pass the current record ID

 

window.showModalDialog("/apex/UpdateFields?id="&{!Opportunity.Id},"","width=400; height=200;");

 

i Kept like this for button. When i am click on that button in the detail page getting "Unexpected token ILLEGAL" in alert box

 

Here am missing in this syntax??

  • March 16, 2013
  • Like
  • 0

Hi,

can anybody tell me what logic should be used to create a child record when the date field changes for the 2nd time onwards...?

 

I have a date field in the parent object when this date field changes don't create the recod when it changes the 2nd time then creates the record...how to do it?

Hello,

 

I am using the OpenCTI API. One of the methods I could use to possibley obtain the logged in user of Salesforce is the method 'runApex'. So, I created an Apex class below. However, I am unable to get the user. Does anybody know how to successfully obtain the salesforce user from the Apex class. Any ideas?

 

global class GetCurrentUser{

    webService static String getUserName(String name) {
        System.debug('User Id: ' + UserInfo.getUserId());
        return UserInfo.getUserId();
    }
}

  • January 26, 2013
  • Like
  • 0

Hello All,
Here is my test class. I am inserting a record into standard object Case. After insertion, when I am trying to fetch the value of case number, it returns null. But the assert statement works fine. Test class works fine.
Why am I not getting the value for the case that is inserted? Any help is greatly appreciated.
Thanks.

private class TestMyTriggerHandler {

private static Id cNumber;

 

     static testMethod void myUnitTest() {

    Test.startTest();

          Case newCase = new Case( Solution__c = 'Test test test'     Description = 'Test test test');

       

        insert newCase;

       System.assert(newCase != null);

       

cNumber = newCase.CaseNumber;

      System.debug('Case Number is ' +cNumber);       

       Test.stopTest(); 

   }

}

Is there an API call I can make to reset my security token?

I understand that I'll need to have my current security token to log in to make that call. I'm wondering if there's a way to reset it, to get a new security token.

Thanks.
After I create a SingleEmailMessage and send it, I can get various attributes of the email - for example, its plainTextBody, htmlBody, etc., but when I look at its getFileAttachments() or getDocumentAttachments() lists, they're always null, even when the email that's actually sent includes attachments. 

Here's the code:
 
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setTemplateId(templateId);
email.setTargetObjectId(contactId);
email.setWhatId(recordId);
Messaging.sendEmail(new List<Messaging.SingleEmailMessage>{email});

System.debug('===== email.getHtmlBody() = ' + email.getHtmlBody().left(20));
System.debug('===== email.getDocumentAttachments() = ' + email.getDocumentAttachments());
System.debug('===== email.getFileAttachments() = ' + email.getFileAttachments());
The System.debug()s show me:
 
===== email.getHtmlBody() = <style>p{margin-top:
===== email.getDocumentAttachments() = null
===== email.getFileAttachments() = null

When I receive the email, it does have an attachment, the file attachment that the email template defines.

Is there any way to get getFileAttachments() to return the attachments?

Thanks!
 
I have a VF page with a custom controller that creates a Customer Community User for a pre-existing Contact record. I'd like to have the Community refrain from sending its standard welcome message to the newly created User. I've added the following to my code, but it still sends the welcome message:
 
User user = new User();
// initialize the other user fields

Database.DMLOptions dmo = new Database.DMLOptions();
dmo.EmailHeader.triggerUserEmail = false;
dmo.EmailHeader.triggerOtherEmail = false;
dmo.EmailHeader.triggerAutoResponseEmail = false;
user.setOptions(dmo);

user insert;
Is there any way to get the Community to not send its standard welcome message to users who are created from this page? (I do want the Community to send the standard welcome message for users who are created from other pages.)
 
I’m about to go live with a Community, and I’ve created a custom domain for it. I’ve created the CNAME entry, and in Salesforce, I configured the Domain and its URL, uploaded a CA-Signed certificate, and added the certificate to the domain, all carefully following the documentation. And I’ve waited several days for everything to propagate. Most of the time, now, when I browse to my custom domain (let’s call it my.abc.com), I see the correct page (the login page), I can log into the Community, and everything is fine.
 
However, for some people, in some browsers, they get a message saying “This connection is untrusted,” like this:

This connection is untrusted

This doesn’t happen for everybody. Most people can use the custom domain just fine, which leads me to believe that the domain and certificate are configured properly. The person who reported this error in Firefox is able to get to the Community just fine using another browser on the same computer on the same network.
 
Telling my Community users to just click “I understand the risks” isn’t an option. Why do some people get this error, and what can I do to prevent it?
 
I need to get a list of all users who are currently logged into my org.

This idea (https://success.salesforce.com/ideaView?id=08730000000BpPOAA0) explains that, as of a few months ago, this is possible. It explains where to find this information via the browser (Setup | Security Controls | Session Management), and also says that it's available through the API. Can anyone point me to documentation that explains how to get it via the API?

Thanks!
I have a VF page that's enabled for Salesforce1. It uses the standard Quote Controller, and generates a PDF view of a Quote. I'd like to be able to see this page from within Salesforce1. Any idea how to make that happen?

Publisher Actions aren't supported for Quotes, so I can't create one.

I can't seem to get a custom "Preview Quote" button to appear in Salesforce1, although it does appear in the standard browser page layout.

I tried creating a formula field on the Quote object that uses the HYPERLINK function to launch the page, and while I can tell from the Debug Log that the page is being launched, it doesn't display in Salesforce1. (I've tried using "_self", "_top", and other options for the HYPERLINK function's third argument, but I see no difference in the results.)

Is there any way to get this PDF to display in SF1 while I'm sitting on the Quote page?
 
I have a Scheduled Batch Apex job that has been running nightly for a couple of months now. The start method does a relatively simple query to get a QueryLocator for a bunch of Attachments. Last night, I got the following error message:

Subject: Developer script exception from <my org name> : 'Batch_Attachments' : java.io.IOException: Missing cursor chunk (offset 0, count 400), key: V:SFDC::x/<my org id>/T/01ga000001i0STTAA2/0.cursor

Apex script unhandled exception by user/organization: 005a0000007hfmB/<my org id>

Failed to process batch for class 'Batch_Attachments' for job id '707a000001BYsGh'


No line number - this appears to be a failure in the Batch Apex system, not in the Apex code. 

Any thoughts on what it means, why it happened, or how to avoid it in the future?

Thanks!
I have a managed package that includes a Permission Set in which I've granted Read and Write access to all of the standard Lead fields. However, when I install the package into an org and then view the Permission Set, some (but not all) of the fields' Read and Write access checkboxes are unchecked. Why? 

For the last couple of days (at least!), http://security.force.com/security/tools/forcecom/scanner has been saying, "At this time the Force.com Security Source Code Scanner is experiencing delays. Expect delays as we work through this issue.

 
If we can't scan our app, we can't submit for Security Review. And the Security Review fees go up NINEFOLD on September 1.
 
Salesforce, can you give us any additional information about this problem or when you expect it to be resolved?
 
Thanks.

When someone installs my managed package in their org, two Leads get created in my org:

 

Lead One:

  • Lead Source = SFDC-IN|listingname (I understand that "IN" means the user started the install process.)
  • Created By is a User in our org
  • Belongs to the Campaign we configured it to belong to in the AppExchange Edit Listing page's Leads tab.
  • Owner = the Owner assigned by our Lead Assignment Rule

Lead Two:

  • Lead Source = Package Installation 
  • Created By is labeled "SFDC LMA DE ORG" but there's no User with the given User Id (00570000001iV8vAAE) in my org
  • Does not belong to a Campaign
  • Owner = the Created By User of Lead One, which is NOT the Owner that should have been assigned by our Lead Assignment Rule
  • Has a License record that points to it

While the AppExchange Publishing Guide (https://appexchange.salesforce.com/resource/1352496302000/help/index_Left.htm) does a reasonable job of explaining the Lead Source Codes and how they apply to Lead One, I don't see any documentation about Lead Two. 

 

  • Who is Lead Two's Created By User, and why it is different from the Created By User of Lead One?
  • According to the documentation, "the lead source code always takes the form of SFDC-XX|Listing Name or SFDC-dup-XX|Listing Name." Yet Lead Two's Lead Source clearly does not take that form. Why not?
  • If Lead One tells me that the user started the install package, what does Lead Two tell me that Lead 1 does not? Why do I have two separate Leads that indicate that my package was installed?
  • Why isn't my Lead Assignment Rule able to assign Lead Two to the same Owner as Lead One? (The Lead Assignment Rule currently essentially assigns all Leads to the same User, so it's not an issue with the rule.)
  • How can I get Lead Two to be owned by the User defined by my Lead Assignment Rule?

The last 3 questions are the most pressing. The others are more a question of curiosity.

 

Thanks!

I have the License Management App installed in an org, and can use it just fine. (I have the System Administrator Profile.) I have another User who has a Profile that uses the "Salesforce" license (not "Salesforce Platform"). I've granted this Profile access to the LMA app and have granted at least Read access to License, Package, and Package Version. However, when I log in as a User with this Profile, while I can see the app in the application pull-down, I can't see the Licenses tab or object.

 

What permissions does a User and/or Profile need in order to use the LMA?

 

Thanks in advance for your help!

The help for "Using Rich Text Area Fields" (https://na5.salesforce.com/help/doc/en/fields_using_rich_text_area.htm) says:

 

  • There are no limits to the number of rich text area and long text area fields that an object can contain, although your Edition's limit for the total number of custom fields allowed on an object, regardless of field type, applies. Each object can contain a total of 1.6 million characters across long text area and rich text area fields. The default character limit for long text area and rich text area fields is 32,768 characters. A long text area or rich text area field needs to contain at least 256 characters.

 

Does this mean that a single record can have at most 1.6 million characters in rich/long text fiels, or that all the rich/long data for an entire object can't exceed 1.6 million?

We have code that does the following:

 

  • Queries CronTrigger to see if there’s an entry for a job with an Id we previously saved in a custom setting.
  • If there is such an entry, calls System.abortJob() to kill that job. If necessary, calls System.abortJob() twice.
  • Schedules the job to run.
  • Saves the Id of the newly-scheduled job in that custom setting

 

Very intermittently, when we save the Id of the newly-scheduled job in the custom setting, we get a Mixed DML error:  First exception on row 0 with id a0E3000000Gj95IEAR; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): OurPkg__Settings__c, original object: CronJobDetail: []

 

The Id (a0E3000000Gj95IEAR) refers to the record for the custom setting.

 

We’re not (of course) touching CronJobDetail directly, and don’t know why we’d get a Mixed DML error for what should be a relatively innocent piece of code, or why the error happens only intermittently. To be clear, we are not doing any direct DML operations on any setup objects -- the closest we come to that is scheduling and aborting jobs.

 

Any thoughts on why we're getting this error, especially only intermittently, and on what we can do to get around it?

 

Thanks.

The Apex Language Reference says the "Total number of classes that can be scheduled concurrently" is 25. 

 

The wording is a little difficult to parse. Which of the following (if any) does this mean?

 

  • I can have at most 25 Schedulable Apex jobs scheduled, even if they're scheduled to run at a wide variety of times that don't overlap
  • I can have at most 25 Schedulable Apex jobs actually running at any one point in time, 

Thanks!

 

I have a beta version of a managed package that I uploaded to the AppExchange maybe 30 minutes ago. (It's beta, and for a privately-listed package, so I can't give the link here.) I've been able to install that version into a Developer Edition org and also to a sandbox, but when I try to install it into one sandbox in particular (one on tapp0), I get the "The requested package does not exist or has been deleted" error. 

 

To reiterate, I *have* successfully installed that version of the package into other orgs, including other sandboxes. I get the error only for that one sandbox.

 

Do uploaded packages take longer to become available on some Salesforce instances than others? Is there an issue with tapp0?  (trust.salesforce.com doesn't think so.) Why would I get this error for just this one sandbox?

 

Thanks.

I'm developing a managed package that needs to behave differently depending on whether its installed in a Trial Edition org, a Developer Edition org, a Sandbox org, or a Production org. Is there any way that Apex can determine what type of Salesforce Edition or org it's running in?

 

(I know how to tell if it's a sandbox -- it's the other editions / org types that I need help with.)

 

Thanks!

I’m about to go live with a Community, and I’ve created a custom domain for it. I’ve created the CNAME entry, and in Salesforce, I configured the Domain and its URL, uploaded a CA-Signed certificate, and added the certificate to the domain, all carefully following the documentation. And I’ve waited several days for everything to propagate. Most of the time, now, when I browse to my custom domain (let’s call it my.abc.com), I see the correct page (the login page), I can log into the Community, and everything is fine.
 
However, for some people, in some browsers, they get a message saying “This connection is untrusted,” like this:

This connection is untrusted

This doesn’t happen for everybody. Most people can use the custom domain just fine, which leads me to believe that the domain and certificate are configured properly. The person who reported this error in Firefox is able to get to the Community just fine using another browser on the same computer on the same network.
 
Telling my Community users to just click “I understand the risks” isn’t an option. Why do some people get this error, and what can I do to prevent it?
 
I have a VF page that's enabled for Salesforce1. It uses the standard Quote Controller, and generates a PDF view of a Quote. I'd like to be able to see this page from within Salesforce1. Any idea how to make that happen?

Publisher Actions aren't supported for Quotes, so I can't create one.

I can't seem to get a custom "Preview Quote" button to appear in Salesforce1, although it does appear in the standard browser page layout.

I tried creating a formula field on the Quote object that uses the HYPERLINK function to launch the page, and while I can tell from the Debug Log that the page is being launched, it doesn't display in Salesforce1. (I've tried using "_self", "_top", and other options for the HYPERLINK function's third argument, but I see no difference in the results.)

Is there any way to get this PDF to display in SF1 while I'm sitting on the Quote page?
 
Hello All,

I have created a VisualForce page with a list that allows the end user to enter the values into the fields all at once.  At the end of each row, they have an option to add another row or to save all the data.  

In standard view, I have a verification rule on one of the Field X that makes sure if Field Y equals a specific value, then Field X cannot be Null.  This works great in the Standard view; however throws an exception error when entering through the VF list.  

I am not sure how to write a code for the VF list that verifies that Field X is not Null when Field Y equals a specific value.  Moreover, I have my list listNewTime and I do not know how to access the data temporarily being stored there prior to running the insert command.  

Thank you in advance. 
I am attempting to match up users coming in from an external POST request to Salesforce users via a SOQL query of the name that returns a user record, then use the ID from the user record to insert a custom object record with a User Lookup field. However I am getting the following error: 
Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, User: id value of incorrect type: 005U0000003GvJKIA0: [User__c]
This error is being thrown because the ID needs to be 15 characters, but is, in practice, coming out as 18 characters. I have tried a few different methods of limiting the string to 15 chars, but to no avail. This is frustrating because it works just fine in the sandbox environment, it is only when deployed to production that this error comes up.

Methods I have tried:

1. No string correction
// match names list to users and create records for each user
        finalCount = names.size();
        for (Integer j = 0; j < finalCount; j++) {
        
            User matchUsr = [SELECT Id, Name
                                FROM User
                                WHERE Name = :names[j]
                                LIMIT 1];
            String usrId = matchUsr.Id;
            
            indivs.add(new Late_Tasks_by_User__c(User__c=usrId,Dependent_Tasks__c=deps[j],Actual_Late_Tasks__c=lates[j],Date__c=datej));
            usrId = '';
            echoOut += names[j] + ', ';
        }

2. Substring the usrId string to (0,15) 
// match names list to users and create records for each user
        finalCount = names.size();
        for (Integer j = 0; j < finalCount; j++) {
        
            User matchUsr = [SELECT Id, Name
                                FROM User
                                WHERE Name = :names[j]
                                LIMIT 1];
            String userMatch = matchUsr.Id;
            String usrId = userMatch.subString(0, 15);
            
            indivs.add(new Late_Tasks_by_User__c(User__c=usrId,Dependent_Tasks__c=deps[j],Actual_Late_Tasks__c=lates[j],Date__c=datej));
            usrId = '';
            echoOut += names[j] + ', ';
        }

3. Take one character from the ID string of the user record at a time (0-14), and add to new usrId string
// match names list to users and create records for each user
        finalCount = names.size();
        for (Integer j = 0; j < finalCount; j++) {
        
            User matchUsr = [SELECT Id, Name
                                FROM User
                                WHERE Name = :names[j]
                                LIMIT 1];
            String userMatch = matchUsr.Id;
            String usrId = '';
            for (Integer xc = 0; xc < 15; xc++) {        
                usrId += userMatch.subString(xc, xc+1);
            }
            
            indivs.add(new Late_Tasks_by_User__c(User__c=usrId,Dependent_Tasks__c=deps[j],Actual_Late_Tasks__c=lates[j],Date__c=datej));
            usrId = '';
            echoOut += names[j] + ', ';
        }

None of these have produced a working result. All three continue to return an 18 character string as the usrId variable. I have found several threads on this forum regarding this topic, but the only solutions that are listed with those questions are either syntax error with the specific code, or someone saying that you have to subString the ID. If anyone has any solutions or ideas beyond that, please let me know.

Thanks,
Joe
Hello all, 

I have been trying to test an Event trigger but I'm kind of lost in a particular part of the execution that I want and need to test.
On the Event object I have a Boolean custom field, has_Attachment__c. So if you insert an attachment in an event this Boolean field will be set to true. How do I test this?  
I use a centralize object initialization class: 
 
public with sharing class EventCentralizeObjectInitialization {
	
	
	 public static List<Event> InitTestInsertEvents(Integer count)
     {
     	
     	Account account = new Account(Name ='testEventAfterInsertAccount'); 
    	insert account; 
    	
    	Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator']; 
        User u = new User(Alias = 'systemAd',
                          Email='systemAd@testorg.com', 
       					  EmailEncodingKey='UTF-8', 
       					  LastName='Testing', 
       					  LanguageLocaleKey='en_US', 
            			          LocaleSidKey='en_US', 
            			          ProfileId = p.Id, 
            			          TimeZoneSidKey='America/Los_Angeles', 
            			          UserName='systemAdEvent@testorg.com');
    	
    	insert u; 
    	
    	DateTime dt = System.now(); 
    	
    		List<Attachment> eventAttMap = new List<Attachment>();
     		Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
     		
     		List<Event> eventList = new List<Event>(); 
     		    		    		        	        	
        	for(Integer x=0; x< count; x++)
        	{
        		eventList.add(new Event(OwnerId = u.Id,
        		                  Subject ='The test subject',
        				  StartDateTime= dt.addMinutes(-120),
        				  EndDateTime = dt,
        				  WhatId = account.id,
        				  Activity_Type__c = 'Inspection')); 
        	}
        	
        	        		
        	return eventList;	
    
       }
         
 }

Then I pull the method InitTestInsertEvents to my test class like this: 
 
@isTest
private class TestEventAfterInsert {

    public static testMethod void testPrepareEventAfterInsert()
    {
    		 
    	List<Event> eventList = EventCentralizeObjectInitialization.InitTestInsertEvents(2); 
    	List<Attachment> attList = new List<Attachment>();
    	List<FeedItem> feedList = new List<FeedItem>();
    	List<Event> eventToUpdate = new List<Event>();
    	Set<Id> ownerIds = new Set<Id>();
    	Set<Id> accountIds = new Set<Id>();
    	Set<Id> eventAttIds = new Set<Id>(); 
    	Id eventID;
    	
    	
    	Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
    	
    	
    	Test.StartTest();  
    	insert eventList;
    	Test.StopTest(); 
    	
    	Map<Id, Event> eventmap = new Map<Id, Event>(eventList);
    	List<Event> events = [SELECT Id, OwnerId, Account.Id, has_Attachment__c, (SELECT Id FROM Attachments) FROM Event WHERE Id IN :eventmap.keySet()]; 	
    	
    	System.assertEquals(events.size(), 2); 
     
     	for(Event e: events)
     	{
     		if(e.Id!=null){
     			attList.add(new Attachment(
     			Name='The test attachment',
     			Body=bodyBlob,
     			ParentId= e.id,
     			OwnerId = e.OwnerId));
     			    			
     		}
     		
     	System.assertNotEquals(attList.size(), 0); 
     	
     	   	
     	}
     	
     	if(!attList.isEmpty() && attList.size()>0)
     	{
     		insert attList; 
       	}
     
     	for(Attachment a: attList)
     	{
     		if(!attList.isEmpty())
     		{
     			Id eventIdAtt = a.ParentId;
     			eventAttIds.add(eventIdAtt);				
     			}
     		}
     		
     	List<Event> eventListAttIds = [SELECT Id, OwnerId, Account.Id, has_Attachment__c FROM Event WHERE Id IN: eventAttIds];	
     	
     		for(Event e: eventListAttIds)
     		{
     			if(!eventListAttIds.isEmpty() && eventListAttIds.size()>0)
     			{
     				e.has_Attachment__c = true;
     				ownerIds.add(e.OwnerId);
     				accountIds.add(e.Account.Id);
     				eventId = e.Id;
     				eventToUpdate.add(e);
     				
     				System.assertEquals(e.has_Attachment__c, true); 
     			}
     		}update eventToUpdate;
     		
     
  }	
}

If I run the test class I only get 47% of the test coverage.
I have been trying different things without getting that percentage higher than 47 :( 

So the question is, how can I pass the events to the test class with an attachment if I can't insert the attachments becasue the ParendIt is not present? Anyone knows how to tests this particular scenario?
Thanks. 
 
  • June 26, 2015
  • Like
  • 0
I have a problem with an integration job and a trigger that seem to be colliding and I was wondering if anyone could help me. There is an integration job running in PowerCenter that takes opportunities and creates contacts from the information on the opportunity. There is also a trigger that runs to update the contact roles when these contacts are created. The trigger is causing problems with the power center job and the power center log shows this error:

2015-06-16 02:58:33 : ERROR : (28559 | WRITER_1_*_1) : (IS | Int_Serv_pcpw_Unicode) : node01_pcpw : WRT_8164 : Error loading into target [Contact] : Error received from salesforce.com. Fields []. Status code [CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY]. Message [ContactOpportunityAssoc: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 200; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [ContactId]: [ContactId]

This is causing some contacts not to get created.

The trigger is called ContactOpportunityAssoc and here's the code:
trigger ContactOpportunityAssoc on Contact (after insert) {
set<String> custnmbr = new set<String>();
Map<String,Id> mapCnts = new Map<String,Id>();
for (Contact c: Trigger.new){
if (c.cnt_plcsc_CustNmbr_ExtID__c != null)
{
custnmbr.add(c.cnt_plcsc_Customer_Number__c);
}
/*List all Contacts that have the customer number the same as the loaded custnmbr set*/ 
mapCnts.put(c.cnt_plcsc_Customer_Number__c , c.Id);
}

List<OpportunityContactRole> ocr = new List<OpportunityContactRole>();
/*List all Contacts that have the customer number the same as the loaded custnmbr set*/
for(Opportunity opp: [Select Id, Customer_Number__c 
From Opportunity 
Where Customer_Number__c IN: custnmbr]){

OpportunityContactRole ocr2 = new OpportunityContactRole();
ocr2.ContactId = mapCnts.get(opp.Customer_Number__c);
ocr2.OpportunityId = opp.Id;
ocr2.IsPrimary = true;
ocr2.Role = 'Primary Insured';
/*System.debug('DLB932 - '+ocr2);*/
ocr.add(ocr2);
}

/*Insert the new list of OCR's*/
if(!ocr.isEmpty())
{insert ocr;}

Thank you!
Hi All

I have creaed a approval process and uploading a PDF document and technical writer will submit for approval process, then approver will receive the email with PDF, however approver receiving the PDF but without content ( blank PDF ). Below is the code, 
<messaging:emailTemplate subject="Document Submitted" recipientType="User" relatedToType="Compliance_Documents__c">
<apex:image url="/servlet/servlet.FileDownload?file=015W0000000Dmru"
height="64" width="64"/>
    <messaging:htmlEmailBody >
        <html>
        <img src="http://www.XXXX.com/ucmprdpub/groups/public/documents/logo/logo_png.png"/>
            <body>
            <p>Dear {!recipient.name},</p>
            
            <p>Attached is document related to Compliance Document "{!relatedTo.Compliance_Document_Name__c} ". </p>
            <p>Please Review the document and <B> Approve/Reject.</B> To approve or reject this item, click this link </p>
            <P>
                <apex:outputLink value="https://cs13.salesforce.com/{!relatedTo.id}">
                    Approve / Reject
                </apex:outputLink>
                <Br/><Br/>or <Br/><Br/>
                <B> To Approve through email :</B> reply to this email with one of these words in the first line of the email message: APPROVE, APPROVED.
                <Br/><Br/>
                <B> To Reject :</B> Please click on the above link.
                <Br/><Br/>
                <B>For Comments: </B>
If replying via email, you can also add comments on the second line. Comments will be stored with the approval request in Salesforce CRM.
            </P>
            <br/> <br/>
           <b> Previous approval history </b>

        <c:ApprovalItem recordId="{!relatedTo.Id}" />
         <br/>
          <br/>
        
            Kind Regards, <br/>
            Document Compliance Team
            
            </body>
        </html>
    </messaging:htmlEmailBody>
    
    <messaging:attachment filename="{!relatedTo.name}" renderAs="PDF">
        <apex:repeat var="cx" value="{!relatedTo.id}">
        </apex:repeat> 
    </messaging:attachment>
</messaging:emailTemplate>



Regards
Shaker
I’m about to go live with a Community, and I’ve created a custom domain for it. I’ve created the CNAME entry, and in Salesforce, I configured the Domain and its URL, uploaded a CA-Signed certificate, and added the certificate to the domain, all carefully following the documentation. And I’ve waited several days for everything to propagate. Most of the time, now, when I browse to my custom domain (let’s call it my.abc.com), I see the correct page (the login page), I can log into the Community, and everything is fine.
 
However, for some people, in some browsers, they get a message saying “This connection is untrusted,” like this:

This connection is untrusted

This doesn’t happen for everybody. Most people can use the custom domain just fine, which leads me to believe that the domain and certificate are configured properly. The person who reported this error in Firefox is able to get to the Community just fine using another browser on the same computer on the same network.
 
Telling my Community users to just click “I understand the risks” isn’t an option. Why do some people get this error, and what can I do to prevent it?
 
I have a SelectList which contains a list of user actions (replaces the need for multiple buttons). I have successfully implemented AcionSupport to invoke an Apex call, but I want to issue a "confirm" dialog on 2 of the actions in the list. My JS skills are very primitive, so I suspect this is not really a difficult task.

Here is my VF code excerpt:

<apex:selectList id="nextAction" value="{!nextAction}" size="1" 
Title="Select the next action">
<apex:selectOptions value="{!nextActionList}"></apex:selectOptions>                        
<apex:actionSupport event="onchange" action="{!doNextAction}" /> 
</apex:selectList>


I want to put an "onchange" event on the selectList which passes the selected option to a JS script which checks the action and optionally displays a confirm warning.

Any help greatly appreciated

 
Good day Ladies and Gents.

I lay before you the fruit of many days of frustration, labor and tears, begging for your help.

There are a few moving parts here, so let me introduce them one by one, with nicknames.

TheVisualForcePage - A humble visualforce page, attached to standard controller User, with a custom extension.

TheVFExtensionCtrl - A braggadocious apex class, who wants the world to know how awesome it is(n't).

TheVFComponentOfDoom - A visualforce component with a custom Controller that exposes two very insubordinate Command buttons. In our case, this component exists to provide a re-usable "delete" button, associated logic and general frustration.

TheVFComponentCtrl - An apex class whose sole purpose in life is to delete an F'ing record. Like the fat kid at primary school sports day, it's main issue is that nobody calls on it. (and therein lies our problem)

To set the stage with these moving pieces, we should consider that the Visualforce page displays, depending on mode, a list of either makes, models or years of cars owned by the given user. Because in my fictional world, users may own multiple Ferrari F12 Berlinetta's (different colors of course.) We can safely assume that if one were to navigate to Farrari, and then Berlinetta, we would see at least one record displayed on our VF page. (2013 of course). These records are displayed in a custom list view format created by using an Apex:Repeat tag.

It's here where we discover our first problem. The list view has, as it's last column a series of "actions" like: "Sell", "Delete" (dear god, who would ever delete a Farrari f12???) and edit. Sell and Delete are command buttons exposed via our handy components. To simply this issue, lets pretend we only have a delete button.

Now, to the untrained, unsuspecting eye a visualforce component, with it's own controller invoked on a page during an Apex:Repeat loop doesn't sound all that complicated. Sure there's the issue of passing in an ID to the logic of the component controller, but that's time-tested, mother approved. Indeed, I thought I was, well, done with this until ...

As it turns out, pressing the delete button has a very curious set of consequences in this setup, consequences I can not fully explain, nor fix.

When you click on the delete command button, the page refreshes (yay, i want that!) However:

Detailed logging shows that the master vfpage's associated controller extension's constructor is executed. Without error
That the component's deleteThisCar method is Never invoked.
Visually, the page state has been lost. What do I mean? I mean that the page that was displaying years of Ferrari F12 Berlinetta's is now just blank, showing only the headers of the listview.

Not to be outdone by an overgrown java app, I've tried the following approaches:

Updating my code to use apex:ActionRegion tags around the components
Tried every damn combination of reRender on the command buttons. Curiously, this had the effect of not reloading the page, and not calling my apex method.
I said, F-IT loudly and refactored the code to not use a component -- invoking an action method directly on the master controller, but this also failed! causing the page to reload, without my action method being invoked
I have slept on the problem. (no joke, this usually works for me. I wake up with the answer.)
I have asked Co-workers to look at it. They suggested the actionRegion bit.
I tried giving up on my trusty commandButtons attempting to use a standard input button with an ActionFunction -- Curiously, this invokes the constructor of my component controller, but not the actual delete function.

Suffice it to say, that overgrown java app is raining on my day.

This feels like somehow the wrong form is being submitted, which is distinctly maddening because i've also rewritten the master vf page such that it had 2 forms (search in header, main page form) and 5 forms (Search in header, 1 form per "mode") Neither has worked.

I realize that it'd be hypocritical in the extreme if I posted this question without some kind of code attached, so here's the component and it's extension. The VF page itself is quite lengthy and I've not finished "sanitizing" it for public consumption.
 
<apex:component controller="ACE_DeleteCarCmpCtrl" allowDML="true">
<apex:attribute name="tv"
    description="ID of the Car model and year to display controls for."
    type="Id"
    required="false"
    assignTo="{!CarVersionId}"
/>
<apex:attribute name="t"
    description="ID of the Car model to display controls for."
    type="ACE_Track__c"
    required="false"
    assignTo="{!Car}"
/>


    <apex:outputPanel layout="block" id="theoutputpanel">
    <apex:actionRegion >
    <!-- <apex:actionFunction name="sayHello" action="{!deleteTrackOrVersion}" rerender="TrackVersionsForSelectedTrack" /> -->
        <apex:commandButton action="{!deleteCarOrYear}"
            value="Delete Car"
            rendered="{!IF(ISNULL(Car), false , true)}"
            styleClass="btn btn-sm btn-default"
            />
        <!-- <input type="button" class="submit" onclick="sayHello"/> -->
        <apex:commandButton action="{!deleteCarOrYear}"
            value="Delete Car Version"
            styleClass="btn btn-sm btn-default"
            rendered="{!IF(ISNULL(CarVersionId), false , true)}"
            rerender="nothing"
            />
    </apex:actionRegion>
    </apex:outputPanel>
</apex:component>
and the controller for it:
public with sharing class ACE_DeleteCarCmpCtrl {

Public ACE_Car_Version__c carVersion {get; set;}
Public Id carVersionId  {get; set { carVersionId = value; }}
Public ACE_Car__c car {get; set;}

public ACE_DeleteCarCmpCtrl() {
    system.debug('$$$$$$$$$$$$$$ : ' + ApexPages.currentPage().getParameters());
}

public PageReference deleteTrackOrVersion() {
    system.debug('************* : ' + ApexPages.currentPage().getParameters());
    try {
        if (car != null && carVersion != null) {
            throw new ACE_contentManagementLib.ContentManagementException('Both car and carVersion cannot be populated when invoking this component');
        } else if (carVersion == null && car == null) {
            throw new ACE_contentManagementLib.ContentManagementException('Both car and carVersion cannot be null when invoking this component');
        } else if (carVersion != null) {
            ACE_ContentManagementLib.deletecarVersion(carVersionId);
        } else if (car != null) {
            ACE_ContentManagementLib.deleteTrack(track);
        }
    } catch (ACE_ContentManagementLib.ContentManagementException e) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
    }
    //return null;
    //Also tried null above. no joy.
    PageReference pageRef = new PageReference('/AwesomePage?id=' + UserInfo.getUserId() );
    system.debug('$$$$$$$$$$$$$$ : ' + ApexPages.currentPage().getParameters());
    pageRef.setRedirect(true);
    return pageRef;
}
}


 
  • February 10, 2015
  • Like
  • 2
I need to get a list of all users who are currently logged into my org.

This idea (https://success.salesforce.com/ideaView?id=08730000000BpPOAA0) explains that, as of a few months ago, this is possible. It explains where to find this information via the browser (Setup | Security Controls | Session Management), and also says that it's available through the API. Can anyone point me to documentation that explains how to get it via the API?

Thanks!
Getting an error Visualforce Page
[Error] Error: Unknown property 'String.Name'

and code is as blow:

<apex:page Controller="AccountList" sidebar="false">
    <script type="text/javascript"
    src="https://maps.google.com/maps/api/js?sensor=false"></script>
    <style>    
        #map {
            font-family: Arial;
            font-size:12px;
            line-height:normal !important;
            height:400px;        
            padding: 20px;
        }       
        .roundCornerCss{ 
            /* outer shadows  (note the rgba is red, green, blue, alpha) */
            -webkit-box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.4); 
            -moz-box-shadow: 0px 1px 6px rgba(23, 69, 88, .5);
            
            /* rounded corners */
            -webkit-border-radius: 12px;
            -moz-border-radius: 7px; 
            border-radius: 7px;
            
            /* gradients */
            background: -webkit-gradient(linear, left top, left bottom, 
            color-stop(0%, white), color-stop(15%, white), color-stop(100%, #D7E9F5)); 
            background: -moz-linear-gradient(top, white 0%, white 55%, #D5E4F3 130%); 
        }   
    </style>
    <script type="text/javascript">                   
        var geocoder;
        var map;
        var infowindow = new google.maps.InfoWindow();
        var places = [];
        var title_content = new Array();                    
        var popup_content = new Array();                    
        var address = new Array();
        var address_position = 0;                    
        var timeout = 600;
        function initialize(){
            geocoder = new google.maps.Geocoder();
            var latlng = new google.maps.LatLng(29.01, 77.38);
            var myOptions = {
              zoom: 2,
              center: latlng,
              mapTypeId: 'roadmap'
            } 
            <apex:repeat value="{!objAccounts}" var="loc" id="addressesId">
                title_content.push("Name: "+"{!loc.Name}"+" \nClick for more Detail");                 
                address.push("{!loc.BillingStreet}, {!loc.BillingCity}, 
                +"{!loc.BillingPostalCode},{!loc.BillingCountry}");
                popup_content.push("<b>Account Name: {!loc.Name}
                +"<br/>Street: {!loc.BillingStreet}"
                +"<br/>City: {!loc.BillingCity}<br/>Postal Code: {!loc.BillingPostalCode}"+
                +"<br/>Country: {!loc.BillingCountry }</b>");                                                    
            </apex:repeat>    
            map = new google.maps.Map(document.getElementById("map"), myOptions);
            addMarker(address_position);
        }        
        function addMarker(position){
            geocoder.geocode({'address': address[position]}, function(results, status){
                if (status == google.maps.GeocoderStatus.OK) {
                    places[position] = results[0].geometry.location;                                    
                    var marker = new google.maps.Marker({
                        position: places[position],
                        title:title_content[position],
                        icon: getMapIconUrl(position+1),
                        map: map
                    });
        
                    google.maps.event.addListener(marker, 'click', function() {
                        if (!infowindow) {
                            infowindow = new google.maps.InfoWindow();
                        }
                        infowindow.setContent(popup_content[position]);
                        infowindow.open(map, marker);
                    });
                }
                else{
                    if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT){
                        setTimeout(function() { addMarker(position); }, (timeout * 3));
                    }
                }
                address_position++;
                if (address_position < address.length){
                    setTimeout(function() { addMarker(address_position); }, (timeout));
                }
            });
        }
        /*
            @Description: To Put diffren color image on Google Map
            @Param: Marker Number to Add on map.
        */
        function getMapIconUrl(markerNumber){
            if(markerNumber > 21){
                markerNumber = markerNumber%20;
            }                    
            var mapIconUrl = "{!URLFOR($Resource.GoogleMarkers, 'GoogleMark/1.png')}";
            var newIcon = markerNumber+'.png';
            mapIconUrl = mapIconUrl.replace('1.png',newIcon);
            return mapIconUrl;
        }         
    </script>  
    <apex:pageMessages />
    <div id="map" class="roundCornerCss"></div>   
    <script>
         initialize();
    </script>
</apex:page>
  • December 06, 2014
  • Like
  • 0
I have an embedded VF page on the Account Detail.  However the page frequently supercedes the height in pixels set by the page layout.  This isn't a problem with scrollbars enabled however the embedded page renders with it scrolled by the bottom by default.  Is there a way around this?

Thanks in advance.
I have a Scheduled Batch Apex job that has been running nightly for a couple of months now. The start method does a relatively simple query to get a QueryLocator for a bunch of Attachments. Last night, I got the following error message:

Subject: Developer script exception from <my org name> : 'Batch_Attachments' : java.io.IOException: Missing cursor chunk (offset 0, count 400), key: V:SFDC::x/<my org id>/T/01ga000001i0STTAA2/0.cursor

Apex script unhandled exception by user/organization: 005a0000007hfmB/<my org id>

Failed to process batch for class 'Batch_Attachments' for job id '707a000001BYsGh'


No line number - this appears to be a failure in the Batch Apex system, not in the Apex code. 

Any thoughts on what it means, why it happened, or how to avoid it in the future?

Thanks!
Well I created a Public Class/Controller, then I couldn't find it (wasn't coming up in any search), so I tried and recreating it, but it says it's already created.  What gives?  This is very bizarre behavior.  
Hi,

I want to use a custom button which takes the user to new contact page . My visualforce page is based on Account standard controller. I am trying to as below , but it give me and errror.
Error: Field $Action.Contact.New does not exist. Check spelling 
Error: Field $Action.Contact.New does not exist. Check spelling.



<apex:page standardController="account" extensions="AccountDetailController">
<apex:commandButton action="{!URLFOR($Action.Contact.New)}" value="New Contact">
</apex:page>

How can i access the action method of contact from account standard controller visualforce page.??

Regards,
raj

I have an unusual problem. I  have developed an Apex class which implments schedulable.  I go into Setup -> Develop -> Apex Classes -> Schedule Apex and fill in the form. Now, when I'm selecting the class I just press the icon to give me a list and it only returns the one class which implements schedulable, which would appear the smart way of letting you select the class.

 

However, I get the following error -

Error: You must select an Apex class that implements the Schedulable interface.

 

I'm really baffled by this, see code below.

 

global class TimesheetWeeklyJob implements Schedulable{
    global void execute( SchedulableContext SC ) {
        WeeklyTimesheetProcess.markSubmitted();
        WeeklyTimesheetProcess.createNewSheets();
    }
}

 

I have a VF page that I'm embedding in a standard page layout. I'd like to pass a parameter into the VF page. The VF page's controller will look at the parameter and the current record, then decide what to display on the embedded page.

 

I have the VF page and controller written. But how can I get the standard page layout editor to pass a parameter in to the VF page? Is that even possible? If not, do you have any other suggestions?

 

Thanks!

  • May 08, 2010
  • Like
  • 0