• Randy Ott
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
Is there a way to directly access the BusinessHoursSettings directly through APEX - without going through the REST API? I need to access this object from a trigger but can't call the REST API from a trigger.
I have a modal lightning component that is designed to create a new object.  I have a custom object that are used to bind the input fields.  When the component is displayed, I want to re-initialize all of the form fields so they are empty.  The first time the modal is displayed - the fields are obviously empty.  However, the next time the modal is displayed, it keeps the data from the previous time even though the fields are reset in javascript code.  I've tried several different ways and nothing seems to work.

Here is the component code:
<aura:component controller="LocationController" >
    <aura:handler event="c:newClassCodePayrollEvent" action="{!c.showModal}"/>

    <aura:attribute name="classCodePayroll" type="ClassCodePayroll__c" default="{ 
                                                                                'sobjectType': 'ClassCodePayroll__c',
                                                                                'Location__c' : '', 
                                                                                'State__c' : '',
                                                                                'Location__r' : {'sobjectType' : 'Location__c', 'Name' : ''},
                                                                                'EstimatedPayroll__c' : '',
                                                                                'FullTimeEmployees__c' : null,
                                                                                'PartTimeEmployees__c' : null,
                                                                                'ClassCodeT__c' : '',
                                                                                'ClassCodeT__r' : {'sobjectType' : 'ClassCode__c', 'Name' : ''}
                                                                                }"/>
    <aura:attribute name="locationId" type="String" default=""/>
    <aura:attribute name="state" type="String" default=""/>
    
    <div class="slds">
        <div aria-hidden="true" role="dialog" class="slds-modal slds-fade-in-hide" aura:id="newClassCodePayrollDialog">
            <div class="slds-modal__container">
                <div class="slds-modal__header">
                    <h2 class="slds-text-heading--medium">New Class Code Payroll</h2>
                    <lightning:buttonIcon class="slds-button slds-button--icon-inverse slds-modal__close" 
                                          iconName="utility:close" alternativeText="Close" onclick="{!c.hideModal}"/>
                </div>
                <div class="slds-modal__content slds-p-around--medium">
                    <div class="slds-grid slds-grid--pull-padded-medium">
                        <div class="slds-col slds-p-horizontal--medium">
                            <div class="slds-hide">
                                <ui:outputText class="slds-form-element__label" value="*State"/>
                                <force:inputField aura:id="stateInput" value="{!v.classCodePayroll.State__c}" required="true"/>
                            	<force:inputField aura:id="locationId" value="{!v.classCodePayroll.Location__c}" class="slds-hide"/>
                            </div>
                            <div class="slds-form-element">
                                <ui:outputText class="slds-form-element__label" value="*Class Code"/>
                                <force:inputField aura:id="classCode" value="{!v.classCodePayroll.ClassCodeT__c}" required="true"/>
                            </div>
                            <div class="slds-form-element">
                                <lightning:input type="number" formatter="currency" label="Estimated Payroll" name="estimatedPayroll" 
                                                 value="{!v.classCodePayroll.EstimatedPayroll__c}" required="true"/>
                            </div>
                        </div>
                        <div class="slds-col slds-p-horizontal--medium">
                            <div class="slds-form-element">
                                <lightning:input type="number" label="Full Time Employees" name="fullTimeEmployees" 
                                                 value="{!v.classCodePayroll.FullTimeEmployees__c}"/>
                            </div>
                            <div class="slds-form-element">
                                <lightning:input type="number" label="Part Time Employees" name="partTimeEmployees" 
                                                 value="{!v.classCodePayroll.PartTimeEmployees__c}"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="slds-modal__footer">
                    <div class="slds-form-element">
                        <button class="slds-button slds-button--neutral" onclick="{!c.hideModal}">Cancel</button>
                        <button class="slds-button slds-button--brand" onclick="{!c.save}">Save</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="slds-backdrop slds-backdrop--hide" aura:id="backdrop"></div>	
    </div>
</aura:component>

Here is the showModal (which calls the initialization helper function):
showModal: function(component, event, helper) {
        helper.showModal(component, event, helper);

        var locationId = event.getParam("locationId");
        var state = event.getParam("state");
        helper.init(component, locationId, state);
	},

And here's the initialization function.  Note the two different ways I have tried to initialize the object two different ways but neither one works.
init: function(component, locationId, state) {
        var ccp = component.get("v.classCodePayroll");
		/* This way doesn't work
        ccp.Location__c = locationId;
        ccp.State__c = state;
        ccp.ClassCodeT__c = "";
        ccp.FullTimeEmployees__c = null;
        ccp.PartTimeEmployees__c = null;
        ccp.EstimatedPayroll__c = "";
        component.set("v.classCodePayroll", ccp);
        */
        
        // This way doesn't work either
        var newCCP = {
            'sobjectType' : ccp.sobjectType, 
            'Location__c' : locationId, 
            'State__c' : state,
            'Location__r' : {'sobjectType' : 'Location__c', 'Name' : ''},
            'EstimatedPayroll__c' : '',
            'FullTimeEmployees__c' : null,
            'PartTimeEmployees__c' : null,
            'ClassCodeT__c' : '',
            'ClassCodeT__r' : {'sobjectType' : 'ClassCode__c', 'Name' : ''},
        };
        component.set("v.classCodePayroll", newCCP);
    },

I have stepped through the javascript code and verified that the object is initialized.  Here's a screenshot of what the object looks like right after the initialization code above:
User-added image

And here's what the modal looks like when it's displayed - with fields from the previous entry:
User-added image
 
I have a lightning component that uses the force:inputField element for a lookup.  The lookup field has a filter applied to it.  I have the filter field displayed on my component, but when I set the value and type into the lookup box, no data is returned.  If I remove the filter from the field, I do get results back.

Here is my lightning component.
<aura:component controller="LocationController" >
    <aura:handler event="c:newClassCodePayrollEvent" action="{!c.showModal}"/>

    <aura:attribute name="classCodePayroll" type="ClassCodePayroll__c" default="{ 'sobjectType': 'ClassCodePayroll__c' }"/>
    <aura:attribute name="locationId" type="String" default=""/>
    <aura:attribute name="state" type="String" default=""/>

    <force:outputField aura:id="locationId" value="{!v.classCodePayroll.Location__c}" class="slds-hide"/>
    
    <div class="slds">
        <div aria-hidden="true" role="dialog" class="slds-modal slds-fade-in-hide" aura:id="newClassCodePayrollDialog">
            <div class="slds-modal__container">
                <div class="slds-modal__header">
                    <h2 class="slds-text-heading--medium">New Class Code Payroll</h2>
                    <lightning:buttonIcon class="slds-button slds-button--icon-inverse slds-modal__close" iconName="utility:close" alternativeText="Close" onclick="{!c.hideModal}"/>
                </div>
                <div class="slds-modal__content slds-p-around--medium">
                    <div class="slds-grid slds-grid--pull-padded-medium">
                        <div class="slds-col slds-p-horizontal--medium">
                            <ui:outputText class="slds-form-element__label" value="State"/>
						    <force:inputField aura:id="stateInput" value="{!v.classCodePayroll.State__c}"/>
                            <ui:outputText class="slds-form-element__label" value="Class Code"/>
                            <force:inputField aura:id="classCode" value="{!v.classCodePayroll.ClassCodeT__c}"/>
                        </div>
                        <div class="slds-col slds-p-horizontal--medium">
                            <lightning:input label="Estimated Payroll" name="estimatedPayroll" value="{!v.classCodePayroll.EstimatedPayroll__c}"/>
                        </div>
                    </div>
                </div>
                <div class="slds-modal__footer">
                    <button class="slds-button slds-button--neutral" onclick="{!c.hideModal}">Cancel</button>
                    <button class="slds-button slds-button--brand" onclick="{!c.save}">Save</button>
                </div>
            </div>
        </div>
        <div class="slds-backdrop slds-backdrop--hide" aura:id="backdrop"></div>	
    </div>
</aura:component>

The lookup field is:
<force:inputField aura:id="classCode" value="{!v.classCodePayroll.ClassCodeT__c}"/>

And the filter field is:
<force:inputField aura:id="stateInput" value="{!v.classCodePayroll.State__c}"/>

Here is an image of the component WITHOUT the filter on the field - which does return results. (Notice two "5552" results for different states)
No Filter Applied

Here is what it looks like when I apply the filter:
With Filter

And finally, here is the standard salesforce create window. Note that the filter is applied correctly.
Standard Create
In my sandbox, the developer console won't display. It opens up a window, immediately resizes to a very small window and hangs.  Chrome eventually times out and I have to kill the session.  I can pull up the console in my production account.
I have a lightning component that uses the force:inputField element for a lookup.  The lookup field has a filter applied to it.  I have the filter field displayed on my component, but when I set the value and type into the lookup box, no data is returned.  If I remove the filter from the field, I do get results back.

Here is my lightning component.
<aura:component controller="LocationController" >
    <aura:handler event="c:newClassCodePayrollEvent" action="{!c.showModal}"/>

    <aura:attribute name="classCodePayroll" type="ClassCodePayroll__c" default="{ 'sobjectType': 'ClassCodePayroll__c' }"/>
    <aura:attribute name="locationId" type="String" default=""/>
    <aura:attribute name="state" type="String" default=""/>

    <force:outputField aura:id="locationId" value="{!v.classCodePayroll.Location__c}" class="slds-hide"/>
    
    <div class="slds">
        <div aria-hidden="true" role="dialog" class="slds-modal slds-fade-in-hide" aura:id="newClassCodePayrollDialog">
            <div class="slds-modal__container">
                <div class="slds-modal__header">
                    <h2 class="slds-text-heading--medium">New Class Code Payroll</h2>
                    <lightning:buttonIcon class="slds-button slds-button--icon-inverse slds-modal__close" iconName="utility:close" alternativeText="Close" onclick="{!c.hideModal}"/>
                </div>
                <div class="slds-modal__content slds-p-around--medium">
                    <div class="slds-grid slds-grid--pull-padded-medium">
                        <div class="slds-col slds-p-horizontal--medium">
                            <ui:outputText class="slds-form-element__label" value="State"/>
						    <force:inputField aura:id="stateInput" value="{!v.classCodePayroll.State__c}"/>
                            <ui:outputText class="slds-form-element__label" value="Class Code"/>
                            <force:inputField aura:id="classCode" value="{!v.classCodePayroll.ClassCodeT__c}"/>
                        </div>
                        <div class="slds-col slds-p-horizontal--medium">
                            <lightning:input label="Estimated Payroll" name="estimatedPayroll" value="{!v.classCodePayroll.EstimatedPayroll__c}"/>
                        </div>
                    </div>
                </div>
                <div class="slds-modal__footer">
                    <button class="slds-button slds-button--neutral" onclick="{!c.hideModal}">Cancel</button>
                    <button class="slds-button slds-button--brand" onclick="{!c.save}">Save</button>
                </div>
            </div>
        </div>
        <div class="slds-backdrop slds-backdrop--hide" aura:id="backdrop"></div>	
    </div>
</aura:component>

The lookup field is:
<force:inputField aura:id="classCode" value="{!v.classCodePayroll.ClassCodeT__c}"/>

And the filter field is:
<force:inputField aura:id="stateInput" value="{!v.classCodePayroll.State__c}"/>

Here is an image of the component WITHOUT the filter on the field - which does return results. (Notice two "5552" results for different states)
No Filter Applied

Here is what it looks like when I apply the filter:
With Filter

And finally, here is the standard salesforce create window. Note that the filter is applied correctly.
Standard Create
Is there a way to directly access the BusinessHoursSettings directly through APEX - without going through the REST API? I need to access this object from a trigger but can't call the REST API from a trigger.
I have a lightning component that uses the force:inputField element for a lookup.  The lookup field has a filter applied to it.  I have the filter field displayed on my component, but when I set the value and type into the lookup box, no data is returned.  If I remove the filter from the field, I do get results back.

Here is my lightning component.
<aura:component controller="LocationController" >
    <aura:handler event="c:newClassCodePayrollEvent" action="{!c.showModal}"/>

    <aura:attribute name="classCodePayroll" type="ClassCodePayroll__c" default="{ 'sobjectType': 'ClassCodePayroll__c' }"/>
    <aura:attribute name="locationId" type="String" default=""/>
    <aura:attribute name="state" type="String" default=""/>

    <force:outputField aura:id="locationId" value="{!v.classCodePayroll.Location__c}" class="slds-hide"/>
    
    <div class="slds">
        <div aria-hidden="true" role="dialog" class="slds-modal slds-fade-in-hide" aura:id="newClassCodePayrollDialog">
            <div class="slds-modal__container">
                <div class="slds-modal__header">
                    <h2 class="slds-text-heading--medium">New Class Code Payroll</h2>
                    <lightning:buttonIcon class="slds-button slds-button--icon-inverse slds-modal__close" iconName="utility:close" alternativeText="Close" onclick="{!c.hideModal}"/>
                </div>
                <div class="slds-modal__content slds-p-around--medium">
                    <div class="slds-grid slds-grid--pull-padded-medium">
                        <div class="slds-col slds-p-horizontal--medium">
                            <ui:outputText class="slds-form-element__label" value="State"/>
						    <force:inputField aura:id="stateInput" value="{!v.classCodePayroll.State__c}"/>
                            <ui:outputText class="slds-form-element__label" value="Class Code"/>
                            <force:inputField aura:id="classCode" value="{!v.classCodePayroll.ClassCodeT__c}"/>
                        </div>
                        <div class="slds-col slds-p-horizontal--medium">
                            <lightning:input label="Estimated Payroll" name="estimatedPayroll" value="{!v.classCodePayroll.EstimatedPayroll__c}"/>
                        </div>
                    </div>
                </div>
                <div class="slds-modal__footer">
                    <button class="slds-button slds-button--neutral" onclick="{!c.hideModal}">Cancel</button>
                    <button class="slds-button slds-button--brand" onclick="{!c.save}">Save</button>
                </div>
            </div>
        </div>
        <div class="slds-backdrop slds-backdrop--hide" aura:id="backdrop"></div>	
    </div>
</aura:component>

The lookup field is:
<force:inputField aura:id="classCode" value="{!v.classCodePayroll.ClassCodeT__c}"/>

And the filter field is:
<force:inputField aura:id="stateInput" value="{!v.classCodePayroll.State__c}"/>

Here is an image of the component WITHOUT the filter on the field - which does return results. (Notice two "5552" results for different states)
No Filter Applied

Here is what it looks like when I apply the filter:
With Filter

And finally, here is the standard salesforce create window. Note that the filter is applied correctly.
Standard Create