• JPSeabury
  • NEWBIE
  • 219 Points
  • Member since 2008
  • Sr. Director, Business Architecture
  • Comcast Business


  • Chatter
    Feed
  • 4
    Best Answers
  • 2
    Likes Received
  • 1
    Likes Given
  • 23
    Questions
  • 66
    Replies
<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,


Is there any way to get current date and time as per the logged in user time zone in apex?

I used System.now(), but its returning as per GMT time zone. I need it as per the user time zone.Like if logged in use time zone is Singapore time zone then it should return current time and date  as per the Singapore time zone which is GMT+8,  not as per the GMT time zone. 


Thanks and Regards,

Rajan Jasuja


One of our sales guys is getting the following error when he opens Word documents:
 
   "Compile error in hidden module: OTWrap"
 
Win XP SP2
Office 2003

Any ideas? He only has Offline and Outlook Edition installed.

One of my test methods is returning the following error:

Case: CaseTriggerHandlerTest
Method: test_insertSingleWebCase
Error: "line -1, column -1: Dependent class is invalid and needs recompilation: Class TestDataFactory : Variable does not exist: ArticleType"

User-added image

While it's true that "ArticleType" doesn't exist in my TestDataFactory apex class, I don't reference that variable in my CaseTriggerHandlerTest class either. The "test_insertSingleWebCase" doesn't reference one either.

Here is the method that is failing in CaseTriggerHandlerTest:

@isTest static void test_insertSingleWebCase() {
        // Mock up a test Web Case
        List<Case> testWebCases = TestDataFactory.createWebCase(1);
        System.debug('testWebCases.size: ' + testWebCases.size() + ' | ' + testWebCases);
        System.AssertEquals(testWebCases.size(), 1);
        
        Id origContactId = testWebCases[0].ContactId;
        String origSuppliedName = testWebCases[0].SuppliedName;
        insert testWebCases[0];
        
        // Query / Reload the Case so we can get the Contact ID, which was not initially provided but should auto update
        Case c = [SELECT Id, ContactId FROM Case WHERE Id = :testWebCases[0].Id];
        
        // Expected Behavior: Contact ID should not be NULL (because the Case Trigger has inserted a new contact)
        System.AssertNotEquals(c.ContactId, NULL);
        
        // Modify the SuppliedName, but add another case with the same SuppliedEmail. Verify you get same c.ContactId
        // (i.e., this should NOT have resulted in a second Contact being created)
        testWebCases = TestDataFactory.createWebCase(1); // get a new case
        testWebCases[0].SuppliedName = 'Surprise!';
        insert testWebCases[0];
        
        c = [SELECT Id, ContactId, SuppliedName FROM Case WHERE Id = :testWebCases[0].Id];
        
        System.AssertNotEquals (origContactId, c.ContactId);
        System.AssertNotEquals(origSuppliedName,c.SuppliedName);
    }


Here is the entire TestDataFactory class:

public abstract class TestDataFactory {
    
    // Account Creation
    public static List<Account> createAccounts (Integer numberOfAccounts) {
        List<Account> accounts = new List<Account>();
        for (Integer i=0 ; i < numberOfAccounts ; i++) {
            Account testAccount = new Account(Name='Test Account' + i);
            accounts.add(testAccount);
        }
		return accounts;
    }
    
    // Contact Creation
    public static List<Contact> createContacts (Account testAccount, Integer numberOfContacts) {
        List<Contact> contacts = new List<Contact>();
        for (Integer i=0; i < numberOfContacts; i++) {
            String strLastName = 'Jones'+i;
            String strEmail = strLastName+'@'+testAccount.Name+'.com';
            strEmail = strEmail.remove(' ');
            Contact testContact = new Contact(LastName=strLastName, AccountId=testAccount.Id, Email=strEmail);
            contacts.add(testContact);
        }
        return contacts;
    }
    
    // Web Case Creation
    public static List<Case> createWebCase (Integer numberOfWebCases) {
        List<Case> testCases = new List<Case>();
        Map<String, Schema.RecordTypeInfo> recordTypes = Schema.SObjectType.Case.getRecordTypeInfosByName();
        Id caseRecordType = recordTypes.get('1819 Case').getRecordTypeId();

        for (Integer i=0; i<numberOfWebCases; i++) {
            String strSuppliedName='Bob Jones'+i;
            String strSuppliedEmail='bob_jones'+i+'@randomdomain.com';
            
            Case testCase = new Case(Status = 'New', 
                                     Priority = 'Normal', 
                                     Origin = 'Email', 
                                     RecordTypeId = caseRecordType,
                           			 SuppliedEmail = strSuppliedEmail, 
                                     SuppliedName = strSuppliedName,
                           			 Subject='Test Case', 
                                     Description='This is a test. This is only a test.');
            testCases.add(testCase);
        }
        
        return testCases;
    }

}
New to DX Projects, and trying to incorporate what I believe is a simple change:

GOAL / OBJECTIVE:
Add a dependent picklist (Loss_Reason__c) to the OpportunityStage Standard Value Set, using SFDX as the package deployment method (rather than ANT Migration Tool). 

The fields (Loss_Reason__c and OpportunityStage) already exist in production, but they have no field dependency association with them. I can certainly add that dependency in Production, but I'm trying to avoid that by using this system change as my first DX Project.

I've enabled DevHub on my produciton org, created a scratch org, and a package.xml that retreives these two fields down from production. 

I've created a scratch org and pushed these two fields into it. I then logged into the sracth org, created the field dependency via Setup, selected which Loss Reason fields were associated with specific OpportunityStage picklist values, etc. Saved changes in the scratch org, and then from VS Code typed:

sfdx force:source:status

Got back:
=== Source Status
No results found

Why is the force:source:status not recognizing that I've made changes in the scratch org that are not present in my local environment?

Is it possible to use SFDX for this example (creating / managing field dependcy on standard and custom fields)?

 

I'm building a custom Visualforce PDF report that shows all the Opportunity Chatter that happened in the past week. I'd like to have the report broken out something similar to:

  • Account 1
    • Oppty 1
      • Oppty Chatter Post 1a
      • Oppty Chatter Post 1b
    • Oppty 2
      • Oppty Chatter Post 2a
      • Oppty Chatter Post 2b
      • Oppty Chatter Post 2c
  • Account 2
    • Oppty 3
      • Oppty Chatter Post 3a
      • Oppty Chatter post 3b

My current code is able to retrieve the Opportunity Chatter Posts easily enough -- but I'm stumped on figuring out how to modify it so that the chatter posts are grouped by Account, as in the example above.

Here's my current VF page:
 

<apex:page controller="ReportOpptyChatter" renderAs="PDF" showHeader="true" sidebar="false">

    <!-- Summary List of all accounts that had Opportunity Chatter this Week -->
    <table>
        <tr><td>Opportunity Chatter found for the following accounts:</td></tr>
        <tr><td>
            <apex:repeat value="{!Accounts}" var="a" >
                <li><apex:outputText value=" {!a.Name}" /> </li>
            </apex:repeat>
        </td></tr>
    </table>
    <p></p>
    
    <!-- Opportunity Chatter -->
    <table>
       <apex:repeat value="{!ChatterUpdate}" var="update" >
       <tr valign="top"><td><b>Project:</b></td><td><apex:outputField value="{!update.ParentId}" /></td><td align="right"><i>{!update.CreatedBy.Firstname} {!update.CreatedBy.Lastname}</i></td></tr>
       <tr valign="top"><td></td><td colspan="2"><apex:outputText value="{!update.Body}" escape="false" /></td></tr>
       <tr><td></td></tr>
       </apex:repeat>
    </table>
</apex:page>


Here's my current controller:

public class ReportOpptyChatter {

    // List of Opportunity Chatter Posts from Last 7 Days    
    List<OpportunityFeed> opptyChatter= [SELECT Id, Body, ParentId, CreatedDate, CreatedBy.FirstName, CreatedBy.LastName
                                         FROM   OpportunityFeed
                                         WHERE  CreatedDate = LAST_N_DAYS:7
                                         ORDER BY CreatedDate];
    
    // Parent accounts of Oppty Chatter
    public List<Account> getAccounts() {
        Set<Id> opptyIdSet = new Set<Id>();   // Which Opportunities had Chatter this past week?        
        Set<Id> acctIdSet = new Set<Id>();    // Which accounts are those opptys related to?
        
        // Interate through the Oppty Chatter to find a list of unique Opptys
        for (OpportunityFeed i : opptyChatter) {
            opptyIdSet.add(i.ParentId);
        }
        List<Opportunity> opptyList = [SELECT Id, Name, AccountId FROM Opportunity WHERE Id IN :opptyIdSet];
        
        // Itegrate through the Opptys to get a list of unique Accounts
        for (Opportunity o : opptyList) {
            acctIdSet.add(o.AccountId);
        }
        List<Account> accountList = [SELECT Id, Name FROM Account WHERE Id IN :acctIdSet ORDER BY Name];
        
        return accountList;
    }
    
    public List<OpportunityFeed> getChatterUpdate() {
        return opptyChatter;
    }

                               
}

I suspect I probably need a wrapper class, so my VF page and modify the VF page to use nested <apex:repeats> but am unsure how to tackle that.

I'm working on the Quick Start: Lightning Web Components Trailhead badge and running into an issue which I think must be related to not setting up my DX Environment correctly.  In module 3 (Create a Hello World Lightning Web Component), I've followed the instructions in the section labeled Create a Lightning Web Component.

The screenshot in the Trailhead module doesn't look at all similar to my results. For the author, their screenshot shows the creation of a helloworld.html, helloworld.js and helloworld.js-meta.xml files. I get the traditional cmp, controller and related files (see my screenshot below).

User-added image

This suggests to me that I've missed something basic, but I've followed the pre-reqs:

1.) I've downloaded / installed Visual Studio Code and the Salesforce Extensions for VS Code
2.) I've verified I'm running a pre-release version of the Salesforce CLI (45.0.12) 

User-added image

3.) I created a PreRelease19 Developer Edition Org of Salesforce, enabled Dev Hub, and authorized it, created a scratch org. 

 

I can't see where I went astray in the trailhead module that caused me to get traditional lightning component artifacts, rather than prerelease lightning web component artifacts (.html, .js, etc.)


Here are my VS logs, in case their useful (I didn't see any clues in them):

Starting SFDX: Authorize a Dev Hub

11:02:58.22 sfdx force:auth:web:login --setdefaultdevhubusername
Successfully authorized ********@force.com with org ID 00DB0000000Tka0MAC
You may now close the browser
11:03:36.238 sfdx force:auth:web:login --setdefaultdevhubusername ended with exit code 0

Starting SFDX: Create a Default Scratch Org...

11:07:04.767 sfdx force:org:create -f config\project-scratch-def.json --setalias HelloWorldLightningWebComponent --durationdays 7 --setdefaultusername
Successfully created scratch org: 00DZ000000NEMayMAH, username: ********@example.com
11:07:20.31 sfdx force:org:create -f config\project-scratch-def.json --setalias HelloWorldLightningWebComponent --durationdays 7 --setdefaultusername ended with exit code 0

Starting SFDX: Create Lightning Component

11:11:14.334 sfdx force:lightning:component:create --componentname helloworld --outputdir force-app\main\default\aura
target dir = c:\Salesforce\HelloWorldLightningCmp\HelloWorldLightningWebComponent\force-app\main\default\aura
   create helloworld\helloworld.cmp
   create helloworld\helloworld.cmp-meta.xml
   create helloworld\helloworldController.js
   create helloworld\helloworldHelper.js
   create helloworld\helloworld.css
   create helloworld\helloworldRenderer.js
   create helloworld\helloworld.svg
   create helloworld\helloworld.auradoc
   create helloworld\helloworld.design

11:11:18.13 sfdx force:lightning:component:create --componentname helloworld --outputdir force-app\main\default\aura ended with exit code 0

 

Where did I go astray? What can I check to validate that I have my SFDX Env setup correctly?

I'm getting the following error on Challenge 7 in the Lightning Experience Rollout Specialist Superbadge:

 

Challenge Not yet complete... here's what's wrong: 
The Account record page must include the required chart with the correct label. Confirm the Opportunities Pipeline report's unique name includes the word "pipeline".


I verified the following:

  1. Account LEX Page has a Tab labeled "Opps by Stage". That tab has a , even though it displays as "Opps By Stage" (see screenshot 1)
  2. My report's unique name was originally "Opportunities_Pipeline_Tt3". I know that upper/lower case sometimes gums up the badge completion validation checks, so I changed the API name to "Opportunities_pipeline_Tt3, since the error says the Report API name must contain the word 'pipeline' (lowercase). (see Screenshot 2)
What am I missing?

Screenshot 1: 
User-added image

Screenshot 2:
User-added image

All of the documented AuthToken methods seem to pass hardcoded values for the Identity Auth. Provider Id (see documentation here: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Auth_AuthToken.htm).

Samples:

String accessToken = Auth.AuthToken.getAccessToken('0SOD000000000De', 'Open ID connect');
Map<String, String> responseMap = Auth.AuthToken.refreshAccessToken('0SOD000000000De', 'Open ID connect', accessToken);the 

I know that using hardcoded Id values in Apex is a no-no, but to get my code up and running, I quickly used hardcoded ID values for Identity Auth Providers in my code. Everything works great in the sandbox, but now that I'm getting ready to deploy to Prod, I'm aware that I'll run into issues. Auth Providers deployed into Production will have a different Id value than those created in the Sandbox. I need to harden the apex code so that it no longer uses these hardcoded Auth Provider ID values.

How can I get the Id value of an Identity Auth Provider regsitered in my org? I don't think I can pull that back with a SOQL statement (similar to how I'd pull back Id values of Profiles, Queues or other objects, can I?

SELECT id FROM ??? 

Thanks for the help, bonus karma points for sample code!

Background Info:
First, some background info, to help give context. Contact records in our Salesforce org are automatically created: we have an integration with an external platform that tracks mobile user registration -- when a user downloads the mobile app from the App Store / Google Play and registers for the product, their peronsal information (first name, last name, email, phone, some other key details) are pushed into Salesforce as a Contact record. If the user updates their information, the contact info in salesforce is updated / refreshed with the new info. 

Anticipating their might be scenarios in which the information wasn't automatically refreshed properly, I added a "Update Contact" button, which triggers a Flow > Apex > HTTP Request callout to the target platform storing contact info. All relatively straight forward, everything works great.

The Issue:
All users must access Salesforce (and other backend systems) via SSO. When I first login, I've noticed I can execute those operations under that "Update Contact" button with no issue -- but if I don't trigger them for 15 minutes, I'll start getting a 401 Response. My HttpRequest AuthHeader uses an Access Token, and I suspect the issue is that token has expires after 15 minutes.  (NOTE: My Salesforce Session settings are set for 2 hours, but that has no bearing on the Access Token -- if I don't make use of it regularly, it will time-out after 15 minutes of no HTTP callouts).

One approach I've considered is that if my HttpRequest gets a 401 response back, then I could prompt the user for their SSO login password and then log back in with a HttpRequest POST containing their credentials. That feels like a cumbersome user experience. The user will be constantly having to enter their SSO password to login if they want to refresh consumer data, do to string time-out rules of our backend env.

Is there a better method for keeping the session alive, so users don't need to provide their SSO credentials on those infrequent occassions where they need to refresh contact info?

 

I'm trying to write a test method for the following Apex class:
 
// JSON File structure for HealthProjectPocHttpCalloutFlow class.

public class HealthProj {
    
    public ContactInformation contactInformation;
    public String access_token;
    public Integer expires_in;
    public String token_type;
    public DateTime lastSynced;
    
    public class ContactInformation {
        public String FirstName;
        public String LastName;
        public String Email;
        public String X1819_User_ID;
        public Date Birthdate;
        public String phone;
        public String MailingStreet;
        public String MailingCity;
        public String MailingCountry;
        public String MailingState;
        public String MailingPostalCode;   
        public String gender;
        public String version;
        public Boolean Active;
    }    
    
    public static HealthProj parse(String json) {
        return (HealthProj) System.JSON.deserialize(json, HealthProj.class);
    }
}

Here is the test method as written so far:
//
// Generated by JSON2Apex http://json2apex.herokuapp.com/
//

@IsTest
public class HealthProj_Test {
    
    static testMethod void testParse() {
        String json = '{'+
            '   \"contactInformation\": {'+
            '        \"FirstName\": \"Joe\", '+
            '        \"LastName\": \"Tester\", '+
            '        \"Email\": \"bbb@ds.com\",  '+
            '       \"X1819_User_ID\": \"4324324234324242342\",'+
            '        \"Birthdate\": \"2018-07-05\",'+
            '       \"phone\": \"382123\",'+
            '       \"MailingStreet\": \"num\",'+
            '       \"MailingCity\": \"NYC\",'+
            '       \"MailingCountry\": \"USA\",'+
            '       \"MailingState\": \"NY\",'+
            '       \"MailingPostalCode\": \"12345\",'+
            '       \"Gender\": \"M\",'+
            '       \"Active\": \"False\",'+
            '       \"Version\": \"1\"'+
            '   }'+
            '}';
        HealthProj obj = HealthProj.parse(json);
        System.assert(obj != null);
    }
}
Salesforce is giving me a JSON Exception system error with the Boolean form:
 
' \"Active\": \"False\",'+

The full error message is System.JSONException: Illegal value for boolean: False at [line:1, column:421]
Class.System.JSON.deserialize: line 15, column 1
Class.HealthProj.parse: line 32, column 1
Class.HealthProj_Test.testParse: line 27, column 1

I've tried using
 
' \"Active\": \"0\",'+
 
with similar failure results.

 

Working on the Lightning Experience Reports & Dashboards Specialist superbadge, I'm at Challenge #7 (Create the SolarBot dashboard) and getting the following error:


There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: IWVYGERW

This is a new trailhead org, created excusively for completing this bage (no other Trailhead modules have been worked in this org). I had a similar unexpected error in a different org, on my previous superbadge -- also when creating dashboards, and corrected it by doing a dashboard refresh. Tried the same thing here, to no avail. Even with a freshly "refreshed" dashboard, I get the error. 

Any suggestions? Could not find the IWVYGERW error code in discussion forum searches.

Working my way through Business Administration Specialist superbadge, challenge step 3. Getting the following error:

"There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: XYJOQBYP"

There was a different unexpected error code that I got initially, but I didn't record the value. I got the first error after I tried changing some of the filter values on my Open Support Cases report to get it to satisfy the challenge check. When that didn't work, I renamed that report and moved it to an archive folder, then created a new Open Support Cases report, updated my dashboard -- and started running into the error above.

Whereas I'm only 3 challenge steps in, I'll probably just generate a new playground and start over -- but sharing the error in the event it's useful.

I'm well outside my comfort zone, so pardon if the question sounds peculiar or if I'm not using the correct terminology!

BACKGROUND:
I have a clean org that is looking to implement SSO for it's internal users (company employees). That seems fairly straight forward with the exhaustive and detailed documentation on this site. 

This org expects to have a number of different partners. We're setting those parter employees up with Communities Plus licenses, and each partner will be "isolated" in their own community.

QUESTION/CHALLENGE TO SOLVE:

Is it possible to have SSO capabilities from different companies into the Salesforce Org?  We want to set up and be responsible for the SSO of our internal users, but we want to give partners the ability to set up their own SSO access to the Communities Plus licenses, as well.

This Authenticate Community Users doc references that "If your organization uses an existing single sign-on capability to simplify and standardize your user authenciation, you can extend this capability to communities".  That wording scares me, becuase it implies that I'm responsible for not only creating Community Plus user licenses, but also setting up those users in our Ping Federate SSO tools. I'm trying to avoid the latter.

Is it possible for different businesses to authenticate different types of users into a single salesforce org?

I am in the process of cleaning up some code written by a consultant. Much of it is neither documented or well commented.  I'm tasked with removing code that isn't used (there has been a ton of it, so far), generally cleaning up the code that's left, bringing the org test coverage up (somehow, they managed to get us down to < 72% coverage), and documenting all of it for our sustaining engineering group.

 

Here is a trigger that's baffled me:

 

trigger copyAccountOwnerBIBI on Account (before insert, before update) {
   for (Integer i=0; i < Trigger.new.size(); i++) {
      Account a = Trigger.new[i];
      try {
         if (a.OwnerIdCopy__c==null || a.OwnerIdCopy__c != a.OwnerId) 
            a.OwnerIdCopy__c = a.OwnerId;
         }
      catch (TypeException e) {
         a.OwnerIdCopy__c = null; 
      }
   }
}

 

Ok, I get what the trigger is supposed to do: copy the account.OwnerId field into the OwnerIdCopy__c field. 

 

Here's what I don't get:

 

What are the cases in which a TypeException error might be thrown by this trigger?  I can't think of any, an am tempted to just remove the try-catch altogether, but hoping someone in the dev community will chime in with, "No, dummy, here's why you need that ...". 

 

If it is needed, what would a test method for that try-catch look like?  Thoughts?

From the UI, is there a simple way to identify where the constructs / methods of a public class are used?  In the UI, when viewing an Apex class, there is a "Show Dependencies" button. When clicked, it shows which Apex classes use the currenlty viewed class -- but I'm looking for the inverse of that: where are methods of the current class evoked?

If not the UI, is there a simple method for doing this in the Eclipse IDE?  The only method I can think of is to build a project with all of my Apex code, and then grep the source files outside the IDE -- but it feels like there should be a simpler way.  Thoughts?

 

USE CASE:  I'm doing some house-cleaning, and finding methods and constructors which I suspect are now deprecated.  If want to remove these from our code base, but need to first confirm that the methods in this public class are not evoked by other classes.

I'm stumped on this one.  I've opened a case with Salesforce Customer Support, but also posting here in the hopes that someone from the User Community might have run into this.

 

Meet Professor Plum:

 

 

Professor Plum is entered in our system as a Person-Account, with access to the Customer Portal:

 

 

 

His profile setting is "Faculty Portal User", which has READ and EDIT permission on the Custom "Faculty Approval" object:

 

 

 

As you can see from this Detail Record view, Professor Plum is the owner of this Faculty Approval record:

 

 

 

Professor Plum needs to do a review of the student named "JP Seabury".  So he logs in to the Customer Portal and pulls up the Faculty Approval record:

 

 

Everything looks in order, so Professor Plum edits the record, rates the candidate, and then tries to save the record.

 

Oh no!  Professor Plum got an error message:

 

 

 

But how is this possible?  Professor Plum IS the record owner.  His user profile has permissions to EDIT this object, and even while the Sharing Rules are private for this object type (so Faculty Members can only see the Faculty Approval requests that have been assigned to them), when I look at the Sharing details for the record, it's confirmed that Professor Plum should be able to update this record:

 

 

 

 

I've checked and double checked:

 

1.) Profile has READ/EDIT privs of the Faculty_Approval__c custom object

2.) Customer Portal User is the record owner

3.) Custom object is viewable to customer portal users

4.) Sharing settings show full access for this customer portal user member.

 

What am I missing? 

Message Edited by JPSeabury on 05-17-2009 01:58 PM

Here's the Apex code I'm writing a testMethod for:

 

public class RequestFacultyApproval {

:

:

:

    public Attachment attachment;  // For uploading attachments to Student obj

:

:

:

 

public PageReference saveAttachment() { // Add the attachment to our Person-Account(Student) record attachment.parentid = StudentDetails.id; insert attachment; // Insert Attachment to both Faculty_Approval__c objects, so it is viewable to Faculty // Members when they access approval form via Customer Portal fac1Attachment = new Attachment(); fac1Attachment.parentid = System.currentPageReference().getParameters().get('fa1'); fac1Attachment.Body = attachment.Body; fac1Attachment.Name = attachment.Name; fac1Attachment.ContentType = attachment.ContentType; insert Fac1Attachment; fac2Attachment = new Attachment(); fac2Attachment.parentid = System.currentPageReference().getParameters().get('fa2'); fac2Attachment.Body = attachment.Body; fac2Attachment.Name = attachment.Name; fac2Attachment.ContentType = attachment.ContentType; insert Fac2Attachment; // redraw the page, so user can see their Attachment has been added to Student record PageReference page = ApexPages.currentPage(); page.setRedirect(true); return page; }

 

    public static testMethod void FacultyApprovalWizard() {

:

:

:

        // Create an attachment, test the SaveAttachment button
        Attachment attachment = new Attachment();
        attachment.Name = 'testAttach';
        attachment.Body = Blob.valueOf( 'this is an attachment test' );
        string pgSaveAttach = rfa.saveAttachment().getUrl();
    }
}

 

During run test, the highlighted section throws the following DML Exception error:

 

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name, Body]: [Name, Body]

 

 

I think I understand why -- the Attachment I'm creating in my testMethod doesn't have any context in the saveAttachment action -- but I'm not sure how to make that happen.

I must be overlooking something very basic, but I don't understand why this code is throwing a DmlException error when I evoke the update.

 

I've stripped the code down to bare basics, hoping the problem would jump out at me - but it isn't.

 

public class FacultyApprovalWizard { private final Account thisStudent; public FacultyApprovalWizard() { thisStudent = [select Id, Name, Department_Notified_GPA__c, X2TOR_Recommendation__c, UNIV_Response_Due__c from Account where id = :System.currentPageReference().getParameters().get('id')]; } public Account getThisStudent() { return thisStudent; } public Attachment attachment { get { if (attachment == null) attachment = new Attachment(); return attachment; } set; } public PageReference saveAttachments() { // Add the attachment to our Person-Account(Student) record attachment.parentid = thisStudent.id; insert attachment; // redraw the page, so user can see their Attachment has been added to Student record PageReference page = ApexPages.currentPage(); page.setRedirect(true); return page; } public PageReference step1() { return Page.RequestFacultyApproval1; } public PageReference step2() { update thisStudent; return null; // return Page.RequestFacultyApproval2; } public PageReference cancel() { PageReference accountPage = new PageReference('/' + thisStudent.id); accountPage.setRedirect(true); return accountPage; } }

 

 

As soon as I hit the Update highlighted, I get this error.

 

 

System.DmlException: Update failed. First exception on row 0 with id 001Q0000002NXtJIAW;

first error: INVALID_FIELD_FOR_INSERT_UPDATE, Account: bad field names on

insert/update call: Name: [Name]

 

Class.FacultyApprovalWizard.step2: line 39, column 7
External entry point

 

 

If it's releveant, these are Person-Account fields (not regular Account fields). Here's the VF page (though I think the problem is in my Apex class):

 

 

<apex:page controller="FacultyApprovalWizard" tabStyle="Account"> <!-- ABSTRACT: Evoked from button on Applied Student Person-Account record type --> <!-- Navigates user through the step of sending Faculty Approval Request and Attachments. --> <!-- TEMP SID: 001Q0000002IwlC --> <apex:sectionHeader title="Submit for Faculty Approval Wizard" subtitle="Step 1: Select Attachments" /> <apex:form > <apex:pageBlock title="Student Information" mode="edit"> <apex:pageBlockButtons location="top"> <apex:commandButton action="{!step2}" value="Step 2: Select Faculty Reviewers" /> <apex:commandButton action="{!cancel}" value="Cancel" /> </apex:pageBlockButtons> <apex:pageBlockSection columns="1"> <apex:outputField value="{!thisStudent.Name}"/> <apex:inputField value="{!thisStudent.Department_Notified_GPA__c}" required="TRUE"/> <apex:inputField value="{!thisStudent.X2TOR_Recommendation__c}" required="TRUE"/> <br/> </apex:pageBlockSection> </apex:pageBlock> <apex:pageBlock title="Select Attachments"> <apex:pageBlockSection > <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}"/> <apex:commandButton value="save" action="{!saveAttachments}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> <apex:relatedList list="NotesAndAttachments" subject="{!thisStudent}"/> </apex:page>

 

I did some stare and compare at this document article, but it looks like we're largely doing similar things.

Message Edited by JPSeabury on 04-21-2009 07:10 PM
I'm writing a VisualForce wizard that collects a list of hardware items (RMA_Return__c) being returned by a customer.  In the VF page, I'd like to control the height and width of the Problem Description field.
 
Picture is worth a thousand words:
 
 
I want to reduce the size of the left InputField box, and increase the width and height of the second InputField box.
 
It looks like <apex:inputText> has a "size" attribute, so you can specify the width of the inputText box, but there isn't a similar attribute for the <apex:inputField> component.
 
There is a "style" attribute, but I'm don't know what CSS syntax would allow me to control this.
 
NOTE:  Still a work in progress, kindly excuse the code hacks here.
 
Current VisualForce Page:
 
Code:
<!-- Create RMA Wizard: Step 2 for Defect / ECO Recall / Shipment Error RMA types -->
<apex:page controller="newRmaController" tabStyle="RMA__c">
  <apex:sectionHeader title="New RMA" subtitle="Step 2 : Select Returning Hardware"/>
  <apex:form >
    <apex:pageBlock title="RMA Detail" mode="edit">
      <apex:pageBlockButtons >
        <apex:commandButton action="{!step1}" value="Previous"/>
        <apex:commandButton action="{!step2}" value="Next"/>
      </apex:pageBlockButtons>
      <apex:pageBlockSection title="RMA Information">
        <apex:inputField id="rmaType" value="{!Rma.Type__c}" required="TRUE"/>
        <apex:inputField id="caseNumber" value="{!Case.casenumber}" />
        <apex:inputField id="caseSwitch" value="{!Case.Switch__c}" required="TRUE"/>
        <apex:inputField id="caseAccount" value="{!Case.Accountid}" required="TRUE"/>
      </apex:pageBlockSection>

      <table width="100%"><tr valign="top">
         <td width="70%">
            <apex:pageBlockSection title="List All Returning Hardware and Reason for Return" columns="1">
               <apex:repeat value="{!RMA_Returns}" var="rtn">
                  <tr>
                     <td width="30%"> <apex:inputField value="{!rtn.SN__c}"/> </td>
                     <td witdh="70%"> <apex:inputField value="{!rtn.Problem_Description__c}"/> </td>
                  </tr>
               </apex:repeat>
               <apex:commandLink action="{!addReturn}" value="Add Card"/>
            </apex:pageBlockSection>
         </td>
         <td width="30%">
            <apex:pageBlockSection title="Installed HW as of Last SAT Audit" columns="1">
               <apex:dataTable id="c3HardwareList" value="{!c3HardwareList}" var="hw" bgcolor="#F3F3EC"
                styleClass="list" rowClasses="dataRow" onRowMouseOver="hiOn(this);" onRowMouseOut="hiOff(this);">
                  <apex:column >
                     <apex:facet name="header"><b>S/N</b></apex:facet>
                     <apex:outputLink value="/{!hw.id}">
                        {!hw.name}
                     </apex:outputLink>
                  </apex:column>
                  <apex:column >
                     <apex:facet name="header"><b>Product Code</b></apex:facet>
                        {!hw.Product_Code__c}
                  </apex:column>
               </apex:dataTable>
            </apex:pageBlockSection>
      </td></tr></table>
      <apex:pageBlockSection title="Ship-To Information : Verify with Customer for Accuracy" collapsible="TRUE" columns="2">
          <apex:inputField id="rmaContact" value="{!Switch.RMA_Contact__c}" />
          <apex:inputField id="rmaPhone" value="{!Switch.RMA_Phone__c}" />
          <apex:inputField id="rmaStreet" value="{!Switch.RMA_Street__c}" />
          <apex:inputField id="rmaCity" value="{!Switch.RMA_City__c}" />
          <apex:inputField id="rmaState" value="{!Switch.RMA_State_Region__c}" />
          <apex:inputField id="rmaZip" value="{!Switch.RMA_Zip_Code__c}" />
          <apex:inputField id="rmaCountry" value="{!Switch.RMA_Country__c}" />
      </apex:pageBlockSection>
    </apex:pageBlock>
    Help: http://forums.sforce.com/sforce/board/message—board.id=Visualforce&message.id=668
  </apex:form>
</apex:page>

 
I'm creating a wizard using VisualForce / Apex, but having some trouble wrapping my head around the best method for doing it.
 
Here are the basics:
  • RMA__c (custom object) tracks the return of materials from customers (Return Material Authorization).  The object captures things like Customer name, RMA reason (hardware defect, product recall, product upgrade, invalid shipment, etc.), RMA request date, etc.  This object is a child in a Master-Detail relationship with the Case object.
  • RMA_Return__c (another custom object) tracks the individual line items of each material being returned: serial number, problem description / return reason, etc.  One field is a lookup to RMA__c (the parent RMA associated with this return).

In the first "page" of the wizard (not shown), we capture basic details (RMA return type, Customer, Case #).

Here's the second page of the wizard:

If that doesn't display well (it doesn't seem to be when I preview the post), click here.

I'm trying to add code to the "Add Card" link in that screenshot.  Clicking that link triggers the "addReturn" method in my Apex code, which is just a stub now.  The behavior that I want is:

Whenever the user clicks "Add Card", the wizard should go grab a new RMA_Return__c, then refresh this page so that there is an additional row of input boxes for the S/N and Problem Description fields. 

The number of RMA_Return__c records related to a RMA__c record is variable -- it's usually 1, but could be 2, 3 ... even dozens.  Because it's variable, I'm thinking I want to use a LIST of these RMA_Return__c records, but I'm not sure how I can display a varying number of these input fields on the refreshed page. 

APEX CONTROLLER

Code:
public class newRmaController {
    public PageReference addReturn() {
        return null;
    }

    Account vAccount;
    Case vCase;
    Switch__c vSwitch;
    RMA__c vRma;
    RMA_Return__c vReturn;
    
    public RMA_Return__c getRMA_Return() {
        if (vReturn == NULL) vReturn = new RMA_Return__c();
        return vReturn;
    }    

    public RMA__c getRma() {
        if (vRma == NULL) vRma = new RMA__c();
        return vRma;
    }
    
    public Case getCase() {
        if (vCase == NULL) vCase = [SELECT id, casenumber, accountid, Switch__c, swrel__c
                                    FROM Case
                                    WHERE id = :System.currentPageReference().getParameters().get('cid')];
        return vCase;
    }
    
    public Switch__c getSwitch() {
        if (vSwitch == NULL) vSwitch = [SELECT id, Last_SAT_Run__c, RMA_Contact__c, RMA_Phone__c, RMA_Street__c, RMA_City__c, RMA_State_Region__c, RMA_Zip_Code__c, RMA_Country__c
                                        FROM Switch__c
                                        WHERE id = :System.currentPageReference().getParameters().get('sid')];

        return vSwitch;
    }
    
    public Hardware__c[] getC3HardwareList() {
        return [SELECT id, name, Product_Code__c
                FROM Hardware__c
                WHERE Switch__c = :System.currentPageReference().getParameters().get('sid')
                ORDER BY name];
    }
    
    public PageReference step1() {
        return Page.CreateRma;
    }

    public PageReference step2() {
        return Page.CreateRmaStep2Defect;
    }

}


 
VISUALFORCE WIZARD - PAGE 2

Code:
<!-- Create RMA Wizard: Step 2 for Defect / ECO Recall / Shipment Error RMA types -->
<apex:page controller="newRmaController" tabStyle="RMA__c">
  <apex:sectionHeader title="New RMA" subtitle="Step 2 : Select Returning Hardware"/>
  <apex:form >
    <apex:pageBlock title="RMA Detail" mode="edit">
      <apex:pageBlockButtons >
        <apex:commandButton action="{!step1}" value="Previous"/>
        <apex:commandButton action="{!step2}" value="Next"/>
      </apex:pageBlockButtons>
      <apex:pageBlockSection title="RMA Information">
        <apex:inputField id="rmaType" value="{!Rma.Type__c}" required="TRUE"/>
        <apex:inputField id="caseNumber" value="{!Case.casenumber}" />
        <apex:inputField id="caseSwitch" value="{!Case.Switch__c}" required="TRUE"/>
        <apex:inputField id="caseAccount" value="{!Case.Accountid}" required="TRUE"/>
      </apex:pageBlockSection>

      <table width="100%"><tr valign="top">
         <td width="70%">
            <apex:pageBlockSection title="S/N of Returning Hardware" columns="2">
               <apex:inputField id="rtnSn" value="{!RMA_Return.SN__c}" />
               <apex:inputField id="rtnDescript" value="{!RMA_Return.Problem_Description__c}" styleClass="data2Col"/>
               <apex:commandLink action="{!addReturn}" value="Add Card"/>
            </apex:pageBlockSection>
         </td>
         <td width="30%">
            <apex:pageBlockSection title="Installed HW as of Last SAT Audit">
            </apex:pageBlockSection>
            <apex:dataTable id="c3HardwareList" value="{!c3HardwareList}" var="hw" bgcolor="#F3F3EC"
             styleClass="list" rowClasses="dataRow" onRowMouseOver="hiOn(this);" onRowMouseOut="hiOff(this);">
             <apex:column >
                 <apex:facet name="header"><b>S/N</b></apex:facet>
                 <apex:outputLink value="/{!hw.id}">
                     {!hw.name}
                 </apex:outputLink>
             </apex:column>
             <apex:column >
                 <apex:facet name="header"><b>Product Code</b></apex:facet>
                 {!hw.Product_Code__c}
             </apex:column>
         </apex:dataTable>
      </td></tr></table>
      <apex:pageBlockSection title="Ship-To Information : Verify with Customer for Accuracy" collapsible="TRUE" columns="2">
          <apex:inputField id="rmaContact" value="{!Switch.RMA_Contact__c}" />
          <apex:inputField id="rmaPhone" value="{!Switch.RMA_Phone__c}" />
          <apex:inputField id="rmaStreet" value="{!Switch.RMA_Street__c}" />
          <apex:inputField id="rmaCity" value="{!Switch.RMA_City__c}" />
          <apex:inputField id="rmaState" value="{!Switch.RMA_State_Region__c}" />
          <apex:inputField id="rmaZip" value="{!Switch.RMA_Zip_Code__c}" />
          <apex:inputField id="rmaCountry" value="{!Switch.RMA_Country__c}" />
      </apex:pageBlockSection>
    </apex:pageBlock>
      Display list of all installed hardware on this Switch</br>
      Provide input fields for users to enter S/N, Reason for Return
  </apex:form>
</apex:page>


Anyone able to jump start my brain on this?

In my sandbox, I have a custom formula field that looks like this:
 
Code:
HYPERLINK("https://cs2.salesforce.com/apex/CreateRma", 
    IMAGE("servlet/servlet.FileDownload—file=015R000000012D8", 
    "Create RMA") )

 
Works great in the sandbox, but when I push this page to my production environment, it will no longer work -- because I've hardcoded the "https://cs2.salesforce.com/" portion of the URL.
 
What is the proper syntax for linking to a Visualforce page as a relative link?
 
 

I've tweaked and reloaded a stylesheet a half-dozen times, working to get the layout "just perfect".  It's kinda cumbersome to have to reload the CSS file from your local machine every time you make a modification to it.

Wouldn't it be cool if you could create custom CSS files from Visualforce?  And edit / save them directly from the Visualforce page editor, too?

Great idea, fancis_gibbons!  Vote: http://ideas.salesforce.com/article/show/10091352/Allow_stylesheets_to_be_created_and_edited_like_Visualforce_pages

All of the documented AuthToken methods seem to pass hardcoded values for the Identity Auth. Provider Id (see documentation here: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Auth_AuthToken.htm).

Samples:

String accessToken = Auth.AuthToken.getAccessToken('0SOD000000000De', 'Open ID connect');
Map<String, String> responseMap = Auth.AuthToken.refreshAccessToken('0SOD000000000De', 'Open ID connect', accessToken);the 

I know that using hardcoded Id values in Apex is a no-no, but to get my code up and running, I quickly used hardcoded ID values for Identity Auth Providers in my code. Everything works great in the sandbox, but now that I'm getting ready to deploy to Prod, I'm aware that I'll run into issues. Auth Providers deployed into Production will have a different Id value than those created in the Sandbox. I need to harden the apex code so that it no longer uses these hardcoded Auth Provider ID values.

How can I get the Id value of an Identity Auth Provider regsitered in my org? I don't think I can pull that back with a SOQL statement (similar to how I'd pull back Id values of Profiles, Queues or other objects, can I?

SELECT id FROM ??? 

Thanks for the help, bonus karma points for sample code!

I'm writing a VisualForce wizard that collects a list of hardware items (RMA_Return__c) being returned by a customer.  In the VF page, I'd like to control the height and width of the Problem Description field.
 
Picture is worth a thousand words:
 
 
I want to reduce the size of the left InputField box, and increase the width and height of the second InputField box.
 
It looks like <apex:inputText> has a "size" attribute, so you can specify the width of the inputText box, but there isn't a similar attribute for the <apex:inputField> component.
 
There is a "style" attribute, but I'm don't know what CSS syntax would allow me to control this.
 
NOTE:  Still a work in progress, kindly excuse the code hacks here.
 
Current VisualForce Page:
 
Code:
<!-- Create RMA Wizard: Step 2 for Defect / ECO Recall / Shipment Error RMA types -->
<apex:page controller="newRmaController" tabStyle="RMA__c">
  <apex:sectionHeader title="New RMA" subtitle="Step 2 : Select Returning Hardware"/>
  <apex:form >
    <apex:pageBlock title="RMA Detail" mode="edit">
      <apex:pageBlockButtons >
        <apex:commandButton action="{!step1}" value="Previous"/>
        <apex:commandButton action="{!step2}" value="Next"/>
      </apex:pageBlockButtons>
      <apex:pageBlockSection title="RMA Information">
        <apex:inputField id="rmaType" value="{!Rma.Type__c}" required="TRUE"/>
        <apex:inputField id="caseNumber" value="{!Case.casenumber}" />
        <apex:inputField id="caseSwitch" value="{!Case.Switch__c}" required="TRUE"/>
        <apex:inputField id="caseAccount" value="{!Case.Accountid}" required="TRUE"/>
      </apex:pageBlockSection>

      <table width="100%"><tr valign="top">
         <td width="70%">
            <apex:pageBlockSection title="List All Returning Hardware and Reason for Return" columns="1">
               <apex:repeat value="{!RMA_Returns}" var="rtn">
                  <tr>
                     <td width="30%"> <apex:inputField value="{!rtn.SN__c}"/> </td>
                     <td witdh="70%"> <apex:inputField value="{!rtn.Problem_Description__c}"/> </td>
                  </tr>
               </apex:repeat>
               <apex:commandLink action="{!addReturn}" value="Add Card"/>
            </apex:pageBlockSection>
         </td>
         <td width="30%">
            <apex:pageBlockSection title="Installed HW as of Last SAT Audit" columns="1">
               <apex:dataTable id="c3HardwareList" value="{!c3HardwareList}" var="hw" bgcolor="#F3F3EC"
                styleClass="list" rowClasses="dataRow" onRowMouseOver="hiOn(this);" onRowMouseOut="hiOff(this);">
                  <apex:column >
                     <apex:facet name="header"><b>S/N</b></apex:facet>
                     <apex:outputLink value="/{!hw.id}">
                        {!hw.name}
                     </apex:outputLink>
                  </apex:column>
                  <apex:column >
                     <apex:facet name="header"><b>Product Code</b></apex:facet>
                        {!hw.Product_Code__c}
                  </apex:column>
               </apex:dataTable>
            </apex:pageBlockSection>
      </td></tr></table>
      <apex:pageBlockSection title="Ship-To Information : Verify with Customer for Accuracy" collapsible="TRUE" columns="2">
          <apex:inputField id="rmaContact" value="{!Switch.RMA_Contact__c}" />
          <apex:inputField id="rmaPhone" value="{!Switch.RMA_Phone__c}" />
          <apex:inputField id="rmaStreet" value="{!Switch.RMA_Street__c}" />
          <apex:inputField id="rmaCity" value="{!Switch.RMA_City__c}" />
          <apex:inputField id="rmaState" value="{!Switch.RMA_State_Region__c}" />
          <apex:inputField id="rmaZip" value="{!Switch.RMA_Zip_Code__c}" />
          <apex:inputField id="rmaCountry" value="{!Switch.RMA_Country__c}" />
      </apex:pageBlockSection>
    </apex:pageBlock>
    Help: http://forums.sforce.com/sforce/board/message—board.id=Visualforce&message.id=668
  </apex:form>
</apex:page>

 
Hi - I have created a flow which is meant to loop through all child records and update a couple of fields. The flow is getting the records correctly, assigning the new field values but on the last record that is updated it isnt adding it to the collection to be updated. Super weird and Ive pasted some of the code below as well as relevant screenshots.
From what I can see in this example:
1. All 5 child records are obtained without a problem
2. The loop goes through each of the records
3. The final record gets new values assigned but it doesnt get included on the update records which happens after the last record (in this case this is the record ending with XUAQ)

any help greatly appreciated

Final part of the flow and the record in question
User-added image
User-added image

2nd image shows only 4 records getting updated
User-added image
 
Hi,

I am new to SalesForce. I am trying to create an app. But when i go to packages and try to create package it says that i am not allowed to create package. 

On clicking devloper settings it given foloowing error

This org is a Developer Hub. You can only create managed packages in a Developer Edition org that isn't your Dev Hub.

I am not sure how can i create a Developer Edition org
New to DX Projects, and trying to incorporate what I believe is a simple change:

GOAL / OBJECTIVE:
Add a dependent picklist (Loss_Reason__c) to the OpportunityStage Standard Value Set, using SFDX as the package deployment method (rather than ANT Migration Tool). 

The fields (Loss_Reason__c and OpportunityStage) already exist in production, but they have no field dependency association with them. I can certainly add that dependency in Production, but I'm trying to avoid that by using this system change as my first DX Project.

I've enabled DevHub on my produciton org, created a scratch org, and a package.xml that retreives these two fields down from production. 

I've created a scratch org and pushed these two fields into it. I then logged into the sracth org, created the field dependency via Setup, selected which Loss Reason fields were associated with specific OpportunityStage picklist values, etc. Saved changes in the scratch org, and then from VS Code typed:

sfdx force:source:status

Got back:
=== Source Status
No results found

Why is the force:source:status not recognizing that I've made changes in the scratch org that are not present in my local environment?

Is it possible to use SFDX for this example (creating / managing field dependcy on standard and custom fields)?

 

I'm building a custom Visualforce PDF report that shows all the Opportunity Chatter that happened in the past week. I'd like to have the report broken out something similar to:

  • Account 1
    • Oppty 1
      • Oppty Chatter Post 1a
      • Oppty Chatter Post 1b
    • Oppty 2
      • Oppty Chatter Post 2a
      • Oppty Chatter Post 2b
      • Oppty Chatter Post 2c
  • Account 2
    • Oppty 3
      • Oppty Chatter Post 3a
      • Oppty Chatter post 3b

My current code is able to retrieve the Opportunity Chatter Posts easily enough -- but I'm stumped on figuring out how to modify it so that the chatter posts are grouped by Account, as in the example above.

Here's my current VF page:
 

<apex:page controller="ReportOpptyChatter" renderAs="PDF" showHeader="true" sidebar="false">

    <!-- Summary List of all accounts that had Opportunity Chatter this Week -->
    <table>
        <tr><td>Opportunity Chatter found for the following accounts:</td></tr>
        <tr><td>
            <apex:repeat value="{!Accounts}" var="a" >
                <li><apex:outputText value=" {!a.Name}" /> </li>
            </apex:repeat>
        </td></tr>
    </table>
    <p></p>
    
    <!-- Opportunity Chatter -->
    <table>
       <apex:repeat value="{!ChatterUpdate}" var="update" >
       <tr valign="top"><td><b>Project:</b></td><td><apex:outputField value="{!update.ParentId}" /></td><td align="right"><i>{!update.CreatedBy.Firstname} {!update.CreatedBy.Lastname}</i></td></tr>
       <tr valign="top"><td></td><td colspan="2"><apex:outputText value="{!update.Body}" escape="false" /></td></tr>
       <tr><td></td></tr>
       </apex:repeat>
    </table>
</apex:page>


Here's my current controller:

public class ReportOpptyChatter {

    // List of Opportunity Chatter Posts from Last 7 Days    
    List<OpportunityFeed> opptyChatter= [SELECT Id, Body, ParentId, CreatedDate, CreatedBy.FirstName, CreatedBy.LastName
                                         FROM   OpportunityFeed
                                         WHERE  CreatedDate = LAST_N_DAYS:7
                                         ORDER BY CreatedDate];
    
    // Parent accounts of Oppty Chatter
    public List<Account> getAccounts() {
        Set<Id> opptyIdSet = new Set<Id>();   // Which Opportunities had Chatter this past week?        
        Set<Id> acctIdSet = new Set<Id>();    // Which accounts are those opptys related to?
        
        // Interate through the Oppty Chatter to find a list of unique Opptys
        for (OpportunityFeed i : opptyChatter) {
            opptyIdSet.add(i.ParentId);
        }
        List<Opportunity> opptyList = [SELECT Id, Name, AccountId FROM Opportunity WHERE Id IN :opptyIdSet];
        
        // Itegrate through the Opptys to get a list of unique Accounts
        for (Opportunity o : opptyList) {
            acctIdSet.add(o.AccountId);
        }
        List<Account> accountList = [SELECT Id, Name FROM Account WHERE Id IN :acctIdSet ORDER BY Name];
        
        return accountList;
    }
    
    public List<OpportunityFeed> getChatterUpdate() {
        return opptyChatter;
    }

                               
}

I suspect I probably need a wrapper class, so my VF page and modify the VF page to use nested <apex:repeats> but am unsure how to tackle that.

I'm working on the Quick Start: Lightning Web Components Trailhead badge and running into an issue which I think must be related to not setting up my DX Environment correctly.  In module 3 (Create a Hello World Lightning Web Component), I've followed the instructions in the section labeled Create a Lightning Web Component.

The screenshot in the Trailhead module doesn't look at all similar to my results. For the author, their screenshot shows the creation of a helloworld.html, helloworld.js and helloworld.js-meta.xml files. I get the traditional cmp, controller and related files (see my screenshot below).

User-added image

This suggests to me that I've missed something basic, but I've followed the pre-reqs:

1.) I've downloaded / installed Visual Studio Code and the Salesforce Extensions for VS Code
2.) I've verified I'm running a pre-release version of the Salesforce CLI (45.0.12) 

User-added image

3.) I created a PreRelease19 Developer Edition Org of Salesforce, enabled Dev Hub, and authorized it, created a scratch org. 

 

I can't see where I went astray in the trailhead module that caused me to get traditional lightning component artifacts, rather than prerelease lightning web component artifacts (.html, .js, etc.)


Here are my VS logs, in case their useful (I didn't see any clues in them):

Starting SFDX: Authorize a Dev Hub

11:02:58.22 sfdx force:auth:web:login --setdefaultdevhubusername
Successfully authorized ********@force.com with org ID 00DB0000000Tka0MAC
You may now close the browser
11:03:36.238 sfdx force:auth:web:login --setdefaultdevhubusername ended with exit code 0

Starting SFDX: Create a Default Scratch Org...

11:07:04.767 sfdx force:org:create -f config\project-scratch-def.json --setalias HelloWorldLightningWebComponent --durationdays 7 --setdefaultusername
Successfully created scratch org: 00DZ000000NEMayMAH, username: ********@example.com
11:07:20.31 sfdx force:org:create -f config\project-scratch-def.json --setalias HelloWorldLightningWebComponent --durationdays 7 --setdefaultusername ended with exit code 0

Starting SFDX: Create Lightning Component

11:11:14.334 sfdx force:lightning:component:create --componentname helloworld --outputdir force-app\main\default\aura
target dir = c:\Salesforce\HelloWorldLightningCmp\HelloWorldLightningWebComponent\force-app\main\default\aura
   create helloworld\helloworld.cmp
   create helloworld\helloworld.cmp-meta.xml
   create helloworld\helloworldController.js
   create helloworld\helloworldHelper.js
   create helloworld\helloworld.css
   create helloworld\helloworldRenderer.js
   create helloworld\helloworld.svg
   create helloworld\helloworld.auradoc
   create helloworld\helloworld.design

11:11:18.13 sfdx force:lightning:component:create --componentname helloworld --outputdir force-app\main\default\aura ended with exit code 0

 

Where did I go astray? What can I check to validate that I have my SFDX Env setup correctly?

I'm getting the following error on Challenge 7 in the Lightning Experience Rollout Specialist Superbadge:

 

Challenge Not yet complete... here's what's wrong: 
The Account record page must include the required chart with the correct label. Confirm the Opportunities Pipeline report's unique name includes the word "pipeline".


I verified the following:

  1. Account LEX Page has a Tab labeled "Opps by Stage". That tab has a , even though it displays as "Opps By Stage" (see screenshot 1)
  2. My report's unique name was originally "Opportunities_Pipeline_Tt3". I know that upper/lower case sometimes gums up the badge completion validation checks, so I changed the API name to "Opportunities_pipeline_Tt3, since the error says the Report API name must contain the word 'pipeline' (lowercase). (see Screenshot 2)
What am I missing?

Screenshot 1: 
User-added image

Screenshot 2:
User-added image
I'm trying to write a test method for the following Apex class:
 
// JSON File structure for HealthProjectPocHttpCalloutFlow class.

public class HealthProj {
    
    public ContactInformation contactInformation;
    public String access_token;
    public Integer expires_in;
    public String token_type;
    public DateTime lastSynced;
    
    public class ContactInformation {
        public String FirstName;
        public String LastName;
        public String Email;
        public String X1819_User_ID;
        public Date Birthdate;
        public String phone;
        public String MailingStreet;
        public String MailingCity;
        public String MailingCountry;
        public String MailingState;
        public String MailingPostalCode;   
        public String gender;
        public String version;
        public Boolean Active;
    }    
    
    public static HealthProj parse(String json) {
        return (HealthProj) System.JSON.deserialize(json, HealthProj.class);
    }
}

Here is the test method as written so far:
//
// Generated by JSON2Apex http://json2apex.herokuapp.com/
//

@IsTest
public class HealthProj_Test {
    
    static testMethod void testParse() {
        String json = '{'+
            '   \"contactInformation\": {'+
            '        \"FirstName\": \"Joe\", '+
            '        \"LastName\": \"Tester\", '+
            '        \"Email\": \"bbb@ds.com\",  '+
            '       \"X1819_User_ID\": \"4324324234324242342\",'+
            '        \"Birthdate\": \"2018-07-05\",'+
            '       \"phone\": \"382123\",'+
            '       \"MailingStreet\": \"num\",'+
            '       \"MailingCity\": \"NYC\",'+
            '       \"MailingCountry\": \"USA\",'+
            '       \"MailingState\": \"NY\",'+
            '       \"MailingPostalCode\": \"12345\",'+
            '       \"Gender\": \"M\",'+
            '       \"Active\": \"False\",'+
            '       \"Version\": \"1\"'+
            '   }'+
            '}';
        HealthProj obj = HealthProj.parse(json);
        System.assert(obj != null);
    }
}
Salesforce is giving me a JSON Exception system error with the Boolean form:
 
' \"Active\": \"False\",'+

The full error message is System.JSONException: Illegal value for boolean: False at [line:1, column:421]
Class.System.JSON.deserialize: line 15, column 1
Class.HealthProj.parse: line 32, column 1
Class.HealthProj_Test.testParse: line 27, column 1

I've tried using
 
' \"Active\": \"0\",'+
 
with similar failure results.

 

Working on the Lightning Experience Reports & Dashboards Specialist superbadge, I'm at Challenge #7 (Create the SolarBot dashboard) and getting the following error:


There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: IWVYGERW

This is a new trailhead org, created excusively for completing this bage (no other Trailhead modules have been worked in this org). I had a similar unexpected error in a different org, on my previous superbadge -- also when creating dashboards, and corrected it by doing a dashboard refresh. Tried the same thing here, to no avail. Even with a freshly "refreshed" dashboard, I get the error. 

Any suggestions? Could not find the IWVYGERW error code in discussion forum searches.

After installing VS Code and adding the Salesforce extensions, I get the error: "Java 8 is required to run. Download and install it from https://java.com/en/download/.", although I have Java 9 running. What can I do to fix that?
Hello,
I tried many times... but receive the same error message : "Challenge Not yet complete... here's what's wrong: 
Formula in custom field 'Account Annual Revenue' is not correct. Check the instructions."
I followed all instructions & get the right results. It's a basic & very simple formula.
Do someone else encounter the same issue ? Any solution ?
I keep getting an error on Item #4 "The custom set of fields that are highlighted on account records must be assigned to the required profile."

The requirement is asking for having highlights based on profiles, but as we know compact layouts are applied to the whole system not by profile.

I am not sure how to fix this, any help is appreciated.
Hi All,

Iam a newbie and i was assigned a challenging task. I would like to edit and modify the CreatedDate field on Lead Object. Is there any way to achieve this. Kindly waiting for the response.

Thanks,
Ram
I'm doing the simple lightning components challenge and have hit this problem in my existing trailhead org and a brand new dev org that I've just created:

Challenge not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: QVWBQHAG

There is Partner Account field on lead object.

Salesforce says,

DescriptionID of the partner account for the partner user that owns this lead. Available only if Partner Relationship Management is enabled OR Communities is enabled and you have partner portal licenses.

 

Although field says lookup,it looks like will be prepopulated when a partner user creates a lead.

 

Is there any way to get content(ID of account) of this field.

 

When i try Lead.PartnerAccount it says field doesnt exist

 

Does anyone have a clue?.It would be really good to get hold of this field 

Our triggers add great new functionality but as of now none are system critial. So for each trigger I have try/catch statements that catch standard exceptions and adds it to a custom built exception log I've created. http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=978\

The problem I've run into is covering the catch code with test coverage.  It seems like a Catch 22. If my test throws an exception it fails, but I somehow need it to throw an exception to cover the catch statement. Even with the catch code not covered we still have 90% code coverage but I'd like to cover as much as possible.

-Thanks
Jason
  • September 05, 2007
  • Like
  • 0
Made some great advances in using SFDX, GIT and VS, mostly admin related stuff right now but we have a developer coming onboard soon.

One question (for now) how do we deal with custom development against an installed AppExchange app?

i.e. We have Linked In Sales Navigator in Production that requies page layout changes, FlexiPage Components, field permissions etc.  I have installed into a Scratch, built everything and pulled the meta into VS (note I am not trying to amend the Managed Package.)

When I come to create an unlocked package I get errors nearly all related to the managed package.  It will be errors like can't add that field because it already exists BUT that field is being included because I have permissions, layouts and maybe flexipages (with components.).  I don't want to add the base data from the managed package because it is installed in Production aleady.

Does it not work?
 
  • February 06, 2020
  • Like
  • 2