• Shubhopedia
  • NEWBIE
  • 30 Points
  • Member since 2017
  • Salesforce Platform Developer


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 6
    Replies
I need help with a validation rule to prevent opening a new record based on the following parameters:
 
IF picklist value of Field1__c = "XXXX" or "YYYY"
THEN
Field2__c cannot be NULL

In other words, Field2__c must have a value (it's a user lookup) when Field1__c is a certain picklist value (there are two options in this case) in order for a record to be created.
​My component code:
​My component code:

​My component code:

<aura:component controller="AccountController" implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global"  >
    <ltng:require styles="/resource/slds221/assets/styles/salesforce-lightning-design-system.min.css" />
    <aura:attribute name="edit" type="Boolean" default="true"/>
    <aura:attribute name="save" type="Boolean" default="false"/>
    <aura:attribute name="cancel" type="Boolean" default="false"/>
    <aura:attribute name="Account" type="Account" default="{ 'sobjectType': 'Account' }"/>
    <aura:attribute name="recordId" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <center>
        <aura:if isTrue="{!v.edit}">
            <lightning:button variant="neutral" label="Edit Info" class="slds-align_absolute-center" onclick="{!c.handleEdit}"/>
        </aura:if>
        <aura:if isTrue="{!v.save}">
            <lightning:button variant="neutral" label="Save Info" class="slds-align_absolute-center" onclick="{!c.handleSave}"/>
        </aura:if>
        <aura:if isTrue="{!v.cancel}">
            <lightning:button variant="neutral" label="Cancel" class="slds-align_absolute-center" onclick="{!c.handleCancel}"/>
        </aura:if>
    </center>
    <div class="slds-form slds-form_stacked">
        <div class="slds-form-element">
            <div class="slds-form-element__control">
                <lightning:select name="selectItem" label="Process Item" disabled="{!!v.save}">
                    <option value="1">Yes</option>
                    <option value="2">No</option>
                </lightning:select>
            </div>
            <label class="slds-form-element__label" for="input-id-03">Process Contact ?</label>
            Save: {!v.Account.Contact__c}
            <aura:renderIf isTrue="{!v.save}">
                <div class="slds-form-element__control">
                    <force:inputField value="{!v.Account.Contact__c}" class="foo" >{!v.Account.Contact__c}</force:inputField>
                </div>
            </aura:renderIf>
            <aura:renderIf isTrue="{!!v.save}">
                <div class="slds-form-element__control">
                  <force:outputField aura:id="accountLookupOutput" value="{!v.Account.Contact__c}"/>
                </div>
            </aura:renderIf>
        </div>
    </div>
</aura:component>
My Js:
({
    doInit : function(component, event, helper) {
        var getaccountdata = component.get("c.getAccount");
        getaccountdata.setParams({ "Id": component.get("v.recordId")});
        getaccountdata.setCallback(this, function(response){      
            var state = response.getState();
            if (state === 'SUCCESS'){
                console.log(response.getReturnValue());
                component.set("v.Account",response.getReturnValue());
            }
        });
        $A.enqueueAction(getaccountdata);
    }

I  get the associated account data for that account and then I set it back to the account variable attribute.
But on page load, I dont see the value in force:outputfield even though that account has that value populated in the field. Its the standard field so ideally it should have shown the value which is already in the account with the standard view .

Can anyone help me on this? if I missed something here
I also tried to put force:output field at the top as well but still the same its blank on page load
 
I need help with a validation rule to prevent opening a new record based on the following parameters:
 
IF picklist value of Field1__c = "XXXX" or "YYYY"
THEN
Field2__c cannot be NULL

In other words, Field2__c must have a value (it's a user lookup) when Field1__c is a certain picklist value (there are two options in this case) in order for a record to be created.
I have 4 or five custom objects each of which have start and end dates associated to them. Within each of the custom objects I have created custom traffic light images which track the end date fields e.g. if end date is greater than 8 days then Green, between 4 & 7 Yellow, below 4 then Red. 
The custom objects in question are all child objects of Accounts.

What I think would be a 'nice to have' feature is if I could show the traffic light information in a component on the Account page layout. Is this possible?
  • March 25, 2018
  • Like
  • 0
Hello, SFDC people.
I am a beginner,
My doubt is that we write the program using APEX Class and also as well as through Anonymous window, what is the difference in writing code on either of them.
please explain me, Thank you.