• Satyavathi Polepally
  • NEWBIE
  • 20 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies
Hi 

I need help to write a test class for a flow which updates the lookup filed on custom object based on the value of another field on the same object.

I have a custom object named Bank__c with lookup relation to Customer__c object. 
On the Bank__c object when Customer1__c text field gets updated with some value it should automatically populate a lookup field called Cust1__c on the Bank__c custom object itself.
I have created the flow to do this. Now I need help to write test class for this one.

Thanks in advance
Hi

I want to get the current month from picklist field and use that current month in soql query in a batch class. I have written the following code and its not working. 
Any help is appreciated.

String month = Product.Month__c.month();
Set<String> ple = new Set<String> {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'};
String query = 'Select Id, Name, Month__c from Product where CALENDAR_MONTH(Month__c) = :month';

 
Hi,  

My requirement is to check if the contact is already exists or not. And, if the contact already exists then I have to check if the contact is subscribed or not. To check the Subscription I have a custom object called Subscription__c. Now I need to query a custom field and check the value of that custom field  on Subscription__c from contact object.
I have written the following code but, its not working. Can somebody help me in fixing this...

KList<Contact> contact = [SELECT Id, Email FROM Contact WHERE Email=:Email];
         if(contact.size() > 0){
         List<Subscription__c> subscription = [SELECT Id,Subscription_Status__c FROM Subscription__c WHERE Contact__c = :contact.Id AND Subscription_Status__c = true Limit 1];
             if(subscription.size() > 0 && subscription.Subscription_Status__c == true){
             }


Note: Contact and Subscription__c are having master detail relationship.
 
Hi I have a requirement where I need to create multiple records in my custom object using REST API POST method.
Now the problem is I am able to create one record at a time and I am not able to create multiple records in one REST API call. I have found on net by passing JSON request body i will be able to create multiple records. 
I am completely new to integration and don't understand how to create mutilple records in one REST API call and how can i pass JSON request body in my REST API.

Can somebody help me in achiving my requirement please.
Here I am posting my code for reference: 
@HttpPost
    global static ID createListofAddresses(String Address, String City, String CompanyName, String CountryCode, String FirstName,
                                      String LastName, String Phone, String PostalCode, String StateCode, String Email
                                       ) {
        //First find the contact id matching the email.
        String ContactId = [SELECT Id
                              FROM Contact
                              WHERE Email = :Email].Id;
        //Second post the new ListofAddresses to the owner of the email.                                 
        List_of_Address__c thisListofAddress = new List_of_Address__c(
            Contact__c=ContactId,
            Address__c=Address,
            City__c=City,
            Company_Name__c=CompanyName,
            Country_Code__c=CountryCode,
            First_Name__c=FirstName,
            Last_Name__c=LastName,
            Phone__c=Phone,
            Postal_Code__c=PostalCode,
            State_Code__c=StateCode
        ); 
              /* List<List_of_Address__c> result = [SELECT Address__c, City__c, Company_Name__c,
                                Country_Code__c, First_Name__c, Last_Name__c, Phone__c, Postal_Code__c, State_Code__c
                                   FROM List_of_Address__c
                                WHERE Contact__c = :ContactId];                          
           if(result.size() > 0){
            return null;
             }else{*/
          insert thisListofAddress;
          return thisListofAddress.Id;
          
             }
Hi All,

I have created a lightning component to display a public site from which we can get customers sigup.
I have created the Lightning component for this and able to view the page but, I am unable to fire the toast messages in this.
And also my Save button is not getting disabled after clicking on it. 
This is my code. Any help to solve this is appreciated. Thanks in advance.
Lightning component:
<aura:component controller="CreateContactrecordController" 
implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:lightningQuickAction,
            flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,lightning:isUrlAddressable,
            lightning:actionOverride,force:hasRecordId"
             access="global" >
    <!-- Include Static Resource-->
    <ltng:require styles="/resource/bootstrap/css/bootstrap.min.css" 
scripts="/resource/bootstrap/js/jquery.js,/resource/bootstrap/js/bootstrap.min.js"/>
    <!--aura:attribute name="isSpinner" type="boolean" default="false"/-->
    <aura:attribute name="FirstName" type="String" default="" />
    <aura:attribute name="LastName" type="String" default="" />
    <aura:attribute name="Mobile" type="String" default="" />
    <aura:attribute name="Email" type="String" default="" /> 
    <aura:attribute name="Store" type="String" />
    <aura:attribute name="LanguageList" type="List" />
    <aura:attribute name="SelectedLanguage" type="String" />
    <aura:attribute name="isHide" type="Boolean" default="false" />
    
     <aura:handler name="onSaveSuccess" event="force:recordSaveSuccess" action="{!c.handleSaveSuccess}"/>
 <force:recordEdit aura:id="edit" recordId=""/>
 <ui:button label="Save" press="{!c.save}"/>
    
    <div class="slds-page-header">
        <div class="slds-align_absolute-center">
            <div class="slds-text-heading_large">
                <div class="slds-m-top_xx-large">
                    Customer Subscription Form
                </div>
            </div>
        </div>
    </div>
    <br/>
    <aura:handler name="init" action="{!c.doinIt}" value="{!this}"/> 
    <div class="slds-form-element__control">
         <lightning:input label="First Name" name="firstname" type="text" required="true" value="{!v.FirstName}" />
        <br/>
        <lightning:input label="Last Name" name="lastname" type="text" required="true" value="{!v.LastName}" />
        <br/>
        <lightning:input label="Mobile" type="tel" value="{!v.Mobile}"/>
        <br/>
        <lightning:input label="Email" name="email" type="email" required="true" value="{!v.Email}" />
        <br/> 
        <lightning:input label="Store" type="Text" name="Store" value="{!v.Store}" />
        <br/> 
        <lightning:select label="Language" name="Language" value="{!v.SelectedLanguage}">
            <aura:iteration items="{!v.LanguageList}" var="Language">
                <option value="{!Language}" text="{!Language}"></option>
            </aura:iteration>
        </lightning:select>
        <br/>
   <lightning:button variant="brand" disabled="{!v.isHide}" label="{!v.isHide == true ? 'Save' : 'Save'}" onclick="{!c.savecustomerForm}" /> 
    <!--lightning:button variant="brand" disabled="{!v.isSpinner}" label="{!v.isSpinner == true ? 'Saving...' : 'Save'}" onclick="{!c.savecustomerForm}" /--> 

    </div>       
</aura:component>

Controller.js:

({
    doinIt: function(component, event, helper){ 
        var action = component.get('c.getPickListValuesIntoList');          
         // method name i.e. getEntity should be same as defined in apex class         
         // params name i.e. entityType should be same as defined in getEntity method        
        //action.setParams({ "entityType" : component.get('v.componentString') });         
            action.setCallback(this, function(a){             
            var state = a.getState(); // get the response state             
            if(state == 'SUCCESS') {
               component.set('v.LanguageList',a.getReturnValue()); 
            }        
            });         
            $A.enqueueAction(action); 
    },
     savecustomerForm: function(component, event, helper) {
        console.log('Create record');
         var action = component.get("c.save");
        //Setting the Apex Parameter
         action.setParams({"FirstName":component.get("v.FirstName"), "LastName":component.get("v.LastName"),
                           "Email":component.get("v.Email"), "Mobile":component.get("v.Mobile"), 
                           "Store":component.get("v.Store"), "Language":component.get("v.Language")
            });
        //Setting the Callback
        action.setCallback(this,function(a){
            //get the response state
            var state = a.getState();
            var isContactexists = a.getReturnValue();
            //check if result is successfull
           
            if(state == "SUCCESS"){
                //Reset Form
                var newContact = {'sobjectType': 'Contact','FirstName': '','LastName': '','Email': '',
                                  'Mobile': '', 'Store__C': '','Language__c' : ''};
                //resetting the Values in the form
                component.set("v.Contact",newContact);
                if(isContactexists===true){
              //alert('Record Created Successfully');
                    component.find("edit").get("e.recordSave").fireeSuccess : function(cmp, event) {
                     // Display the save status
                     var toastEvent = $A.get("e.force:showToast");
                     toastEvent.setParams({
                     "title": "true!",
                     "message": "My Custom Record Saved Successfully"
 });
 toastEvent.fire();
                    }
                    
                component.set('v.isHide', true);  
                }
                else { 
                   alert('Record already exists'); 
                   
                }
            }
            else if(state == "ERROR"){
            alert('Error in calling server side action');
           
            }
            
        });
                
         $A.enqueueAction(action);}

})

Apex controller:

public class CreateContactrecordController {
@AuraEnabled
     public static List<String> getPickListValuesIntoList()
     {
       List<String> pickListValuesList= new List<String>();
        Schema.DescribeFieldResult fieldResult = Contact.Language__C.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        for( Schema.PicklistEntry pickListVal : ple){
            pickListValuesList.add(pickListVal.getLabel());
        }    
        return pickListValuesList;
    }
 @AuraEnabled   
    public static Boolean save(String FirstName, String LastName, String Email, String Mobile, String Store, String Language )
    {
        List<Contact> Contact = [SELECT Id, Email From Contact WHERE Email=:Email];
         if(contact.size() > 0){
             return false;
        }else{
            Contact con=new Contact(); 
            con.FirstName = FirstName;
            con.LastName = LastName;
            con.Email = Email;
            con.MobilePhone = Mobile;
            con.Store__c = Store;
            con.Language__c = Language;
            insert con;
            return true;
        }
    }
    }
 
Hi

I want to get the current month from picklist field and use that current month in soql query in a batch class. I have written the following code and its not working. 
Any help is appreciated.

String month = Product.Month__c.month();
Set<String> ple = new Set<String> {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'};
String query = 'Select Id, Name, Month__c from Product where CALENDAR_MONTH(Month__c) = :month';

 
Hi,  

My requirement is to check if the contact is already exists or not. And, if the contact already exists then I have to check if the contact is subscribed or not. To check the Subscription I have a custom object called Subscription__c. Now I need to query a custom field and check the value of that custom field  on Subscription__c from contact object.
I have written the following code but, its not working. Can somebody help me in fixing this...

KList<Contact> contact = [SELECT Id, Email FROM Contact WHERE Email=:Email];
         if(contact.size() > 0){
         List<Subscription__c> subscription = [SELECT Id,Subscription_Status__c FROM Subscription__c WHERE Contact__c = :contact.Id AND Subscription_Status__c = true Limit 1];
             if(subscription.size() > 0 && subscription.Subscription_Status__c == true){
             }


Note: Contact and Subscription__c are having master detail relationship.
 
Hi I have a requirement where I need to create multiple records in my custom object using REST API POST method.
Now the problem is I am able to create one record at a time and I am not able to create multiple records in one REST API call. I have found on net by passing JSON request body i will be able to create multiple records. 
I am completely new to integration and don't understand how to create mutilple records in one REST API call and how can i pass JSON request body in my REST API.

Can somebody help me in achiving my requirement please.
Here I am posting my code for reference: 
@HttpPost
    global static ID createListofAddresses(String Address, String City, String CompanyName, String CountryCode, String FirstName,
                                      String LastName, String Phone, String PostalCode, String StateCode, String Email
                                       ) {
        //First find the contact id matching the email.
        String ContactId = [SELECT Id
                              FROM Contact
                              WHERE Email = :Email].Id;
        //Second post the new ListofAddresses to the owner of the email.                                 
        List_of_Address__c thisListofAddress = new List_of_Address__c(
            Contact__c=ContactId,
            Address__c=Address,
            City__c=City,
            Company_Name__c=CompanyName,
            Country_Code__c=CountryCode,
            First_Name__c=FirstName,
            Last_Name__c=LastName,
            Phone__c=Phone,
            Postal_Code__c=PostalCode,
            State_Code__c=StateCode
        ); 
              /* List<List_of_Address__c> result = [SELECT Address__c, City__c, Company_Name__c,
                                Country_Code__c, First_Name__c, Last_Name__c, Phone__c, Postal_Code__c, State_Code__c
                                   FROM List_of_Address__c
                                WHERE Contact__c = :ContactId];                          
           if(result.size() > 0){
            return null;
             }else{*/
          insert thisListofAddress;
          return thisListofAddress.Id;
          
             }
I want to display or update  pic  awhen ever i want Example in linekedin there is profilepic where we can change our pic when ever we want like wase i want to update in community using lighting component


#Thanks in advance