• Laura Bejjani
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 5
    Replies
I have a requirement to build a custom component for Customer Community to create a new case. On the form I have a lookup field to a custom object that doesn't want to work. Are lookups to custom objects suppose to work in communities? Here's a simplified version of my code.
 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="Case" type="Case"  />
<aura:attribute name="newCase" type="Object"  />
<aura:attribute name="simpleNewCase" type="Object" />
<aura:attribute name="newCaseError" type="String" />
<force:recordData aura:id="caseRecordCreator"
                  fields="Location__c,LocationTest__c,Number_of_Required_Extensions__c,Primary_Use_for_Numbers__c,Extension_End_Range__c"
                  targetRecord="{!v.newCase}"
                  targetFields="{!v.simpleNewCase}"
                  targetError="{!v.newCaseError}" />

<!-- First we initialize the form -->
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />

<lightning:recordEditForm objectApiName="Case"
                          onsubmit="{!c.handleSaveCase}" >
                        <lightning:inputField fieldName="Location__c" />
                        <lightning:inputField fieldName="OwnerId" />
                        <lightning:inputField fieldName="LocationTest__c" />
                        <lightning:inputField fieldName="ContactId" />
                        <lightning:input label="Input" value="{!v.case.LocationTest__c}"/>
</lightning:recordEditForm> 

</aura:component>


({
doInit : function(component, event, helper) {
    //Standard way to load a record template using Lightning Data Service
    component.find("caseRecordCreator").getNewRecord(
        "Case",
        "0122a0000008c9lAAA",
        false,
        $A.getCallback(function(){
            var rec = component.get("v.newCase");
            var error = component.get("v.newCaseError");
            if(error || (rec === null)){
                console.log("Error initializing record template: " + error);
            }else{
                console.log("Record template initialized" + rec.sobjectType);
            }
        })
    );
},

    handleSaveCase : function(component, event, helper){
    //This is how we link the new Contact with the actual Account Id
    //component.set("v.simpleNewCase.AccountId", component.get("v.simpleUser.AccountId"));        
    //alert("{!v.simpleUser.AccountId}");
    //component.set("v.simpleNewCase.ContactId", component.get("v.simpleUser.ContactId"));

    //Standard way to save a record using Lightning Data Service
    component.find("caseRecordCreator").saveRecord(function(saveResult){
        if(saveResult.state === "SUCCESS" || saveResult.state === "DRAFT"){
            //resultToast is a pop-up window that show messages.
            var resultsToast = $A.get("e.force:showToast");
            resultsToast.setParams({
                "title" : "Case saved",
                "message" : "The new case was created",
                "type" : "success"
            });

            $A.get("e.force:closeQuickAction").fire();
            resultsToast.fire();
            $A.get("e.force:refreshView").fire();
        }else if(saveResult.state === "INCOMPLETE"){
            console.log("User is offline, device doesn't support drafts.");
        }else if(saveResult.state === "ERROR"){
            console.log("Problem saving case, error" + JSON.stringify(saveResult.error));
        }else{
            console.log("Unknown problem, state: " + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));
        }
    });
}})

Why isn't the Location lookup showing any values?
I'm building a questionnaire form that shows and hides the customer questions depending on values they select from a picklist on the case object. So when the customer is creating a new case if they select value A they get asked the questions where the type = A. I created a Question object with a type picklist because I didn't want to overload the case object with a 100 questions. What kind of relationship do I need to create to only show Questions of type A on a case when A is selected in the picklist? 
Hi, 

I have a Description field of type Long Text Area. I'm trying to get the first few lines to display. I tried creating a formula field LEFT(Description, 500) I get Error: You referenced an unsupported field type called "Long Text Area" using the following field: Description. I tried using SOQL but I couldn't. I also tried something like                        
<apex:outputText value="{!LEFT(GoodMorning,4)}"/> and couldn't get it to work. How can I get a substring of the description field to show up in an page. 
I'm trying to show/hide a bunch of fields depending on the case's related product(s). For example - If a user is having an issue with their desktop app I want to show fields like IOS or Android. If the user is having an issue with their desktop I want to show desktop related fields. The user can be having an issue with both Mobile and Desktop, in that case, I would like to show both sets of fields. I want to do this for both internal salesforce users and community users. I'm new to Salesforce Development and have not done any Visual Force Development. I tried to create a junction table with master-detail relationship with a custom question object and product object but the product object didn't show up as an option. I was thinking I could create the relationship and use filtering on the related record component in the case page. What's the best way to accomplish setting field visibility based on the product(s) type. 
I'm trying to accomplish the following. A case has a Start Date/time and End Date/time, and a Server field. A custom Incident Object also has an Incident Name, Start Date/time and End Date/time and Server field. After those fields are filled out and the case is saved. I would like a url to any icidents that happened on the same server, and date/time.  
I created a custom object called Incident. The incident object . I added a Server drop down in the Case object. I want to create a relashionship ship between Case and Incident based on the Server field. When I create the lookup, it shows the Incident Name. I want it to show the Server. When a Case is created, the Server field is not always known so I can't make it a required field. Is it possible to create that kind of relashionship and how? Is it possible to create the url field in the case object? If not, is it possible to create a count of related incidents? There isn't always a relashionship between the two, it depends on the server. 
I have a requirement to build a custom component for Customer Community to create a new case. On the form I have a lookup field to a custom object that doesn't want to work. Are lookups to custom objects suppose to work in communities? Here's a simplified version of my code.
 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="Case" type="Case"  />
<aura:attribute name="newCase" type="Object"  />
<aura:attribute name="simpleNewCase" type="Object" />
<aura:attribute name="newCaseError" type="String" />
<force:recordData aura:id="caseRecordCreator"
                  fields="Location__c,LocationTest__c,Number_of_Required_Extensions__c,Primary_Use_for_Numbers__c,Extension_End_Range__c"
                  targetRecord="{!v.newCase}"
                  targetFields="{!v.simpleNewCase}"
                  targetError="{!v.newCaseError}" />

<!-- First we initialize the form -->
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />

<lightning:recordEditForm objectApiName="Case"
                          onsubmit="{!c.handleSaveCase}" >
                        <lightning:inputField fieldName="Location__c" />
                        <lightning:inputField fieldName="OwnerId" />
                        <lightning:inputField fieldName="LocationTest__c" />
                        <lightning:inputField fieldName="ContactId" />
                        <lightning:input label="Input" value="{!v.case.LocationTest__c}"/>
</lightning:recordEditForm> 

</aura:component>


({
doInit : function(component, event, helper) {
    //Standard way to load a record template using Lightning Data Service
    component.find("caseRecordCreator").getNewRecord(
        "Case",
        "0122a0000008c9lAAA",
        false,
        $A.getCallback(function(){
            var rec = component.get("v.newCase");
            var error = component.get("v.newCaseError");
            if(error || (rec === null)){
                console.log("Error initializing record template: " + error);
            }else{
                console.log("Record template initialized" + rec.sobjectType);
            }
        })
    );
},

    handleSaveCase : function(component, event, helper){
    //This is how we link the new Contact with the actual Account Id
    //component.set("v.simpleNewCase.AccountId", component.get("v.simpleUser.AccountId"));        
    //alert("{!v.simpleUser.AccountId}");
    //component.set("v.simpleNewCase.ContactId", component.get("v.simpleUser.ContactId"));

    //Standard way to save a record using Lightning Data Service
    component.find("caseRecordCreator").saveRecord(function(saveResult){
        if(saveResult.state === "SUCCESS" || saveResult.state === "DRAFT"){
            //resultToast is a pop-up window that show messages.
            var resultsToast = $A.get("e.force:showToast");
            resultsToast.setParams({
                "title" : "Case saved",
                "message" : "The new case was created",
                "type" : "success"
            });

            $A.get("e.force:closeQuickAction").fire();
            resultsToast.fire();
            $A.get("e.force:refreshView").fire();
        }else if(saveResult.state === "INCOMPLETE"){
            console.log("User is offline, device doesn't support drafts.");
        }else if(saveResult.state === "ERROR"){
            console.log("Problem saving case, error" + JSON.stringify(saveResult.error));
        }else{
            console.log("Unknown problem, state: " + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));
        }
    });
}})

Why isn't the Location lookup showing any values?
Hi, 

I have a Description field of type Long Text Area. I'm trying to get the first few lines to display. I tried creating a formula field LEFT(Description, 500) I get Error: You referenced an unsupported field type called "Long Text Area" using the following field: Description. I tried using SOQL but I couldn't. I also tried something like                        
<apex:outputText value="{!LEFT(GoodMorning,4)}"/> and couldn't get it to work. How can I get a substring of the description field to show up in an page. 
I'm trying to accomplish the following. A case has a Start Date/time and End Date/time, and a Server field. A custom Incident Object also has an Incident Name, Start Date/time and End Date/time and Server field. After those fields are filled out and the case is saved. I would like a url to any icidents that happened on the same server, and date/time.  
I created a custom object called Incident. The incident object . I added a Server drop down in the Case object. I want to create a relashionship ship between Case and Incident based on the Server field. When I create the lookup, it shows the Incident Name. I want it to show the Server. When a Case is created, the Server field is not always known so I can't make it a required field. Is it possible to create that kind of relashionship and how? Is it possible to create the url field in the case object? If not, is it possible to create a count of related incidents? There isn't always a relashionship between the two, it depends on the server. 

i not understanding usage of junction object .

Please explain usage and how to create junction object with a example