• Joseph Winter
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 3
    Replies
We have a Lightning App Page created in the Lightning App Builder.
One of the components is a visualforce page. We are trying to use a custom label to translate the title of this added component.

The information icon on the "Label" field in the app builder suggests if this is left blank, the title of the page is used. However adding a "title" property in the <apex:page> definition does not help.

User-added imageUser-added image
User-added image


 
I am creating a datatable to display a list of events, hosted on a lightning component designed for mobile.

I want to be able to navigate to a record in the datatable when clicking on the record's label. In this instance, making the column of type URL does not properly work in the mobile app, so i must use "e.force:navigateToURL" to handle the navigation to the record. To achieve this, I made the column of type "button".

To get the right record Id, i have stored the Id of the record as the "name" attribute of the button, (see line 4 of the JS Controller) and want to retrieve this from the buttons event (see line 25 of the JS Controller). For some reason, this value is always returned as "undefined" when logged.
 
<aura:component controller="LtngCtrlEventsList"  implements="force:appHostable,flexipage:availableForAllPageTypes" access="global">
    
	<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
               
    <aura:attribute name="eventsList" type="Object" access="public"/>
    <aura:attribute name="columnsList" type="List" access="public"/>
    
    <lightning:card iconName="standard:event" title="Today's Events">
        <div class="slds-p-horizontal_medium">
            <lightning:datatable
                                 keyField="id"
                                 data="{!v.eventsList}"
                                 columns="{!v.columnsList}"
                                 hideCheckboxColumn="true"
                                 onrowaction="{!c.redirect}"/> 
        </div>
    </lightning:card>
   
</aura:component>
 
({
	doInit : function(component, event, helper) {
        component.set("v.columnsList",[
            {label: "Subject", fieldName: "linkName", type: "button", typeAttributes: {label: {fieldName: 'Subject'}, name: {fieldName : 'Id'}, onClick: '{!c.redirect}'}},
            {label: "Time", fieldName: "StartDateTime", type: "date", typeAttributes: {hour:"2-digit", minute:"2-digit"}},
            {label: "Concerning", fieldName: "WhatName", type: "text"}
        ]);
        var action = component.get("c.getUserEvents");
        action.setCallback(this, function(a) {
            if (a.getState() == 'SUCCESS'){
                var response = a.getReturnValue();
                console.log(response);
                response.forEach(function(record){
                    record.linkName = "{!v.directToRecord}";
                    if(record.What) record.WhatName = record.What.Name;
                });
                component.set("v.eventsList", response);
            }
        });
        $A.enqueueAction(action);
        
	},
    
    redirect : function(component, event, helper){
        console.log(event.getSource().get("v.name")); 
        var urlEvent = $A.get("e.force:navigateToURL");
        urlEvent.setParams({
          "url": "/" + event.getParam("name")
        });
        urlEvent.fire();
    }
    
})
I can confirm the button is rendered with the "name" attribute populated, as seen below:
User-added image
Why is this the case? The "event.getSource().get("v.name")" retrieves nothing even though the button is a "lightning:button".

Please advise on whether this is a limitation of the lightning:datatable or not.
Thanks
Hi all,
We are creating a custom case form using lightning:recordEditForm and lightning:inputField. The form is generated off of a fieldset here;
<lightning:recordEditForm aura:id="test"
                              objectApiName="{! v.sObjectName }"
                              recordId="{! v.recordId }"
                              recordTypeId="{! v.recordTypeId }">
        <lightning:messages />

        <aura:iteration items="{! v.fields }" var="field">
            <lightning:inputField aura:id="caseField" fieldName="{! field.APIName }" class="slds-p-top_small slds-m-top_medium"/>
        </aura:iteration>
        
        <lightning:button class="slds-m-top_small" type="submit" label="Save" /></lightning:recordEditForm>
The fieldset is passed correctly with all the correct information. The desired result comes through ok hosted in an App here;
User-added image

The issue is when the component is placed in a community, the HTML generated has the fields as 'disabled';
User-added image
We cannot seem to find a permission in the Guest user profile that would cause this. Case is Read/Create, all fields on Case are Read/Edit Access, and all Record Types have been made available. None of the fields in the field set have been set to Read-Only.

Perplexed as to why this is happening, and can't seem to find a lot of documentation surrounding the new lightning:recordEditForm.

Appreciate any input.
Thanks,

Hi,
Here I have made a trigger that;
- When an Opportunity is set to 'Closed Won' or 'Closed Lost', set all Opportunities belonging to the same Account to 'Closed Lost';
 

trigger OppsChangeCloses on Opportunity (after update) {
	if(AvoidRecursion.isFirstRun()){
		List<Opportunity> opps = [SELECT Id, StageName, AccountId FROM Opportunity WHERE Id IN :Trigger.new];

		for(Opportunity o: opps){

			System.debug('Opportunity Id:' + o.Id + ' | New-StageName = ' + o.StageName + ' | Old-StageName = ' + trigger.oldMap.Get(o.id).StageName); 

			//If opportunity has had its StageName updated
			if((o.StageName == 'Closed Won' || o.StageName== 'Closed Lost' ) && o.StageName != trigger.oldMap.Get(o.id).StageName){
				//List accounts with affected opportunities
				List<Account> accounts = [SELECT Id, (SELECT Id, StageName, Name FROM Opportunities) FROM Account WHERE Id = :o.AccountId];
				System.debug('Account ID : ' + o.accountId);
				for(Account a :accounts){
					for(Opportunity relatedOpp : a.opportunities){
						if(relatedOpp.id != o.id){
							System.debug('Other Op ID: ' + relatedOpp.Id + ' | Other Op Name: '+ relatedOpp.Name );

							System.debug('StageName Before: ' + relatedOpp.stageName);
							relatedOpp.stageName = 'Closed Lost';
							System.debug('StageName After: ' + relatedOpp.stageName);

							update relatedOpp;
						}
					}
				}
			}
		}
	}
}

The debugging I have done on the class seem to imply it should work, but my testing class disagrees.
 
@isTest
private class testOppsChangeCloses {

	static List<Opportunity> opps;
	static List<Account> accs;


	static void setup(){
		opps = new List<Opportunity>();
		accs = new List<Account>();

		Account a1 = new Account(Name = 'Test1');
		Account a2 = new Account(Name = 'Test2');
		accs.add(a1);
		accs.add(a2);
		insert accs;

		Opportunity o1 = new Opportunity(Name = 'TestOp1', CloseDate = (System.Today() + 7), StageName = 'Prospecting', AccountID = a1.Id);
		Opportunity o2 = new Opportunity(Name = 'TestOp2', CloseDate = (System.Today() + 7), StageName = 'Prospecting', AccountID = a1.Id);	
		Opportunity o3 = new Opportunity(Name = 'TestOp3', CloseDate = (System.Today() + 7), StageName = 'Prospecting', AccountID = a2.Id);
		Opportunity o4 = new Opportunity(Name = 'TestOp4', CloseDate = (System.Today() + 7), StageName = 'Prospecting', AccountID = a2.Id);	
		opps.add(o1);
		opps.add(o2);
		opps.add(o3);
		opps.add(o4);
		
		insert opps;

	}
	
	@isTest static void testOne() {
		Test.startTest();
		setup();

		//Change TestOp1 StageName to 'Close Won'
		System.debug('StageName Before Change: ' + opps[1].StageName);
		opps[0].StageName = 'Closed Won';
		update opps[0];
		System.debug('StageName After Change: ' + opps[1].StageName);
		System.debug('TestOp2 ID: ' + opps[1].ID + ' | TestOp2 Name' + opps[1].Name);

		//Is TestOp1's Stage 'Closed Won'?
		System.assertEquals('Closed Won', opps[0].StageName);
		
		//Is TestOp2's Stage 'Closed Lost'?
		System.assertEquals('Closed Lost', opps[1].StageName);

		Test.stopTest();
	
	}
	
	
}

The output of the debug lines are as follows;
 User-added image
As you can see, within the trigger, any related opportunities (of which there is one, TestOp2), are updated to 'Closed Lost'.
But in the Test methord, after the first opportunity is updated, the related opportunity seems to remain as 'Prospecting'

I know the code is quite messy and inefficient (I was to rework this after i got this working), but I would really appreciate a hand here. I may have just misconstructed the test class.

Thanks

Hi. Working through the Visualforce Mobile module, and im haivng throuble with the 3rd unit. 

Im getting this issue:
"Challenge Not yet complete... here's what's wrong: 
The 'MobileContactList' Visualforce page does not appear be displaying the contact name or contact phone."


The code I am using is:

<apex:page showHeader="true" sidebar="true" standardController="Contact" recordSetVar="contacts">
	<head>
	<apex:slds />
	</head>


	<apex:repeat value="{!contacts}" var="c">
		<dl class="slds-list_horizontal slds-wrap">
			<dt class="slds-item_label slds-text-color_weak slds-truncate" title="Contact Name:">{!c.Name}</dt>
			<dd class="slds-item_detail slds-truncate" title="Mobile Phone Number:">{!c.MobilePhone}</dd>
		</dl>
	</apex:repeat>

</apex:page>
Which then displays this;

User-added image
Which looks like it works, as long as the Contacts list view is set to view all (otherwise nothing displays).

Is this just another case of the trailhead looking for a very specific solution? I can't seem to find much help on this one.

Thanks
Hi all,

I am working through the Visualforce Mobile trailhead, and in the "Use the Salesforce Lightning Design System to Style Visualforce Pages" module, the first step of the exercise defines this class;
 
<apex:page showHeader="false" standardStylesheets="false" sidebar="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0">

  <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" lang="en">
    <head>
      <meta charset="utf-8" />
        <meta http-equiv="x-ua-compatible" content="ie=edge" />
        <title>SLDS LatestAccounts Visualforce Page in Salesforce Mobile</title>
        <meta name="viewport" content="width=device-width, initial-scale=1" />

      <!-- Import the Design System style sheet -->
      <apex:slds />
    </head>     
    <body>

      <!-- REQUIRED SLDS WRAPPER -->
      <div class="slds-scope">

         <!-- PRIMARY CONTENT WRAPPER -->
         <div class="myapp">

         </div>
         <!-- / PRIMARY CONTENT WRAPPER -->

      </div>
      <!-- / REQUIRED SLDS WRAPPER -->

      <!-- JAVASCRIPT -->
      <!-- / JAVASCRIPT -->
    </body>
  </html>
</apex:page>
When the class is saved, an error is produced:
"The API version you've specified is lower than the minimum version of 39 for the apex:slds object"
This happens in both the developer console and mavensmate/sublime. 

Is there any way to fix this so I can continue the module?

Thanks
Hi all,
We are creating a custom case form using lightning:recordEditForm and lightning:inputField. The form is generated off of a fieldset here;
<lightning:recordEditForm aura:id="test"
                              objectApiName="{! v.sObjectName }"
                              recordId="{! v.recordId }"
                              recordTypeId="{! v.recordTypeId }">
        <lightning:messages />

        <aura:iteration items="{! v.fields }" var="field">
            <lightning:inputField aura:id="caseField" fieldName="{! field.APIName }" class="slds-p-top_small slds-m-top_medium"/>
        </aura:iteration>
        
        <lightning:button class="slds-m-top_small" type="submit" label="Save" /></lightning:recordEditForm>
The fieldset is passed correctly with all the correct information. The desired result comes through ok hosted in an App here;
User-added image

The issue is when the component is placed in a community, the HTML generated has the fields as 'disabled';
User-added image
We cannot seem to find a permission in the Guest user profile that would cause this. Case is Read/Create, all fields on Case are Read/Edit Access, and all Record Types have been made available. None of the fields in the field set have been set to Read-Only.

Perplexed as to why this is happening, and can't seem to find a lot of documentation surrounding the new lightning:recordEditForm.

Appreciate any input.
Thanks,

Hi. Working through the Visualforce Mobile module, and im haivng throuble with the 3rd unit. 

Im getting this issue:
"Challenge Not yet complete... here's what's wrong: 
The 'MobileContactList' Visualforce page does not appear be displaying the contact name or contact phone."


The code I am using is:

<apex:page showHeader="true" sidebar="true" standardController="Contact" recordSetVar="contacts">
	<head>
	<apex:slds />
	</head>


	<apex:repeat value="{!contacts}" var="c">
		<dl class="slds-list_horizontal slds-wrap">
			<dt class="slds-item_label slds-text-color_weak slds-truncate" title="Contact Name:">{!c.Name}</dt>
			<dd class="slds-item_detail slds-truncate" title="Mobile Phone Number:">{!c.MobilePhone}</dd>
		</dl>
	</apex:repeat>

</apex:page>
Which then displays this;

User-added image
Which looks like it works, as long as the Contacts list view is set to view all (otherwise nothing displays).

Is this just another case of the trailhead looking for a very specific solution? I can't seem to find much help on this one.

Thanks
Hi all,

I am working through the Visualforce Mobile trailhead, and in the "Use the Salesforce Lightning Design System to Style Visualforce Pages" module, the first step of the exercise defines this class;
 
<apex:page showHeader="false" standardStylesheets="false" sidebar="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0">

  <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" lang="en">
    <head>
      <meta charset="utf-8" />
        <meta http-equiv="x-ua-compatible" content="ie=edge" />
        <title>SLDS LatestAccounts Visualforce Page in Salesforce Mobile</title>
        <meta name="viewport" content="width=device-width, initial-scale=1" />

      <!-- Import the Design System style sheet -->
      <apex:slds />
    </head>     
    <body>

      <!-- REQUIRED SLDS WRAPPER -->
      <div class="slds-scope">

         <!-- PRIMARY CONTENT WRAPPER -->
         <div class="myapp">

         </div>
         <!-- / PRIMARY CONTENT WRAPPER -->

      </div>
      <!-- / REQUIRED SLDS WRAPPER -->

      <!-- JAVASCRIPT -->
      <!-- / JAVASCRIPT -->
    </body>
  </html>
</apex:page>
When the class is saved, an error is produced:
"The API version you've specified is lower than the minimum version of 39 for the apex:slds object"
This happens in both the developer console and mavensmate/sublime. 

Is there any way to fix this so I can continue the module?

Thanks