• Santosh Reddy Maddhuri
  • SMARTIE
  • 561 Points
  • Member since 2016


  • Chatter
    Feed
  • 19
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 114
    Replies
I've taken over our org from the previous dev and even though I'm not a developer (I'm the admin) I need to fix this issue. I have limited dev experience but I figured I'll give this a shot.
We are using lightning components for our opportunities. We also have a few custom fields on the page layout as well in addition to the lightning component. 
The lightning component has a custom button that changes the stages of the opportunity. 
I would like to add a line of code to that button that will also change the value of one of the custom picklists. This picklist does not exist in the lightning component - it's just a custom field on the layout itself. 
The button click action is on the ComponentHelper.js so I'm adding the line there but I'm having issues.
The custom field is Demo_Audit_Status__c so I thought the line of code would be:
component.set("Demo_Audit_Status__c", "No Demo Needed");
I'm pretty sure I'm oversimplifying what I need but I'd rather fix this before having to reach out to the original devs.
Hi, I'm very new to Apex (>1 month) and can't debug this error. I've spent about a day on it.  I'm trying to implement the USPS API to validate Lead Addresses

This is my class:
public with sharing class addressValidation {

    String url = 'http:production.shippingapis.com/ShippingAPI.dll?API=Verify&XML=';

    public static HttpResponse getResponse(Lead addressToVerify) {

        String XMLToAttach = '<AddressValidateRequest USERID="<MYIDGOESHERE>">';

        String addr = cleanAddress(addressToVerify);
        XMLToAttach = XMLToAttach + addr;
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('url');
        request.setMethod('GET');

        try {
            HttpResponse res = http.send(request);
            System.debug('Log the status code ' + res.getStatusCode());
            System.debug('log the res body ' + res.getBody());
            Dom.Document doc = res.getBodyDocument();

            Dom.XMLNode address = doc.getRootElement();
            return res;
        }
        catch(Exception e) {
            System.debug('Error calling USPS web service' + e.getMessage());
            return null;
        }
    }


    private static String cleanAddress(Lead address){
        String xmlAddress = '';
        String street = '';
        String city = '';
        String state = '';
        String zip = '';

        street = address.street;
        city = address.city;
        state = address.state;
        zip = address.postalCode;

        xmlAddress = '<Address><street>'+street+'</street>';
        xmlAddress += '<City>'+city+'</City><State>'+state+'</State><Zip>'+zip+'</Zip></Address></AddressValidateRequest>';
        System.debug('This is the xml address being sent' + xmlAddress);
        return xmlAddress;
    }
}
Test method:
/**
 * Created by AlyssaCooper on 3/27/2019.
 */
@IsTest
public with sharing class addressValidationTest {

        @IsTest static void testCallout() {
        Lead testLead = new Lead (
            Street = '123 Street',
            City = 'Boston',
            State = 'Massachusetts',
            PostalCode = '12456',
            LastName = 'Cooper',
            Company = 'Fake Company'
        );
        Test.startTest();

        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
        HttpResponse res = addressValidation.getResponse(testLead);

//        Verify response received contains fake values
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/xml');
        String actualValue = res.getBody();
        String expectedValue = '{"street": "", "city": "", "state": "", "zip": ""}';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, res.getStatusCode());
        Test.stopTest();
    }
}

MockHttpResponseGenerator
public with sharing class MockHttpResponseGenerator implements HttpCalloutMock{
    // Implement this interface method
    String url = 'http:production.shippingapis.com/ShippingAPI.dll?API=Verify&XML=';
    public HTTPResponse respond(HTTPRequest req) {

        System.assertEquals('url', req.getEndpoint());
        System.assertEquals('GET', req.getMethod());

        // Create a fake response
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/xml');
        res.setBody('{"street": "", "city": "", "state": "", "zip": ""}');
        res.setStatusCode(200);
        return res;
    }

}


 
I am trying to display comment icon as a place holder for a text field but not able to add it as expected.
Following is the peace of code i am refering 
<apex:page showHeader="false" standardStylesheets="false" sidebar="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0">
<style>
  .inputFieldClass
   {
        height: 40px;
        width: 400px;
        /* color: green; */
        /*border-color: green;*/
        background-image: "http://icons.iconarchive.com/icons/bokehlicia/captiva/256/chat-bubbles-icon.png" ;
        background-repeat: no-repeat;
        text-indent: 20px;
   }
   

</style>
    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" lang="en">

    <head>
        <apex:slds />
    </head>    
    <body>
        <div class="slds-scope">
            <div class="slds-grid">
                <div class="slds-col slds-size_1-of-6">
                    <ul class="slds-list--vertical slds-has-inline-block-links--space">
                        <li class="slds-list__item"><a href="#void">Geeting started</a></li>
                        <li>
                            <ul class="slds-list--vertical slds-is-nested">
                                <li class="slds-list__item"><a href="#void">Find a place</a></li>
                                <li class="slds-list__item"><a href="#void">Experience</a></li>
                            </ul>
                        </li>
                        <li class="slds-list__item"><a href="#void">Booking your trip</a></li>
                        <li class="slds-list__item"><a href="#void">Payments</a></li>
                        <li class="slds-list__item"><a href="#void">Yours Trips</a></li>
                    </ul>
                </div>
                <div class="slds-col slds-size_5-of-6">
                    <div id="mydiv" class="slds-size_1-of-2 slds-p-top_x-large" >      
                            <h5 class="slds-text-heading_large" style="font-weight: 600;">How are we doing ?</h5>
                    </div>
                    <div class="slds-p-top_medium">
                        We are always there to improve our expeience so we would love to hear what's working and how we could make it better.
                    </div>
                    <div class="slds-p-top_medium">
                        <h1 style="display:inline ;font-weight: 700;" >This isn't the way to contact us ,through. </h1>
                        We can't reply to bug report indvijually. If you have question regarding solving problem. you will find answer in help center or you can 
                        <h1 style="color: darkseagreen;"><a href="">contact us. </a></h1>      
                    </div>
                    <div class="slds-p-top_xx-large">
                        <div style="font-weight :600 ;">
                            What would you like to do ?  
                                <div class="slds-grid slds-gutters">    
                                &#xf075;
                                    <div class="form-group" style="font-weight :500 ;">
                                        <span class="inputFieldClass11"><i class='icon-search'></i></span>
                                        <input name="firsttext" class="inputFieldClass" placeholder="&#xF002; dsafffffffffff" onchange="hideImage()"/>  
                                        <input type="text" placeholder="&#xF002; Search" style="font-family:Arial, FontAwesome" />
                                        <textarea placeholder='&#xf075; Add Comment'></textarea>
                                    </div>
                                    <div class="slds-col">
                                        <span>2</span>
                                    </div>
                                </div>    
                        </div>
                    </div>
                    
                </div>
            </div>
        </div>
    </body>

    </html>
</apex:page>
I am trying to create a detail page button that marks a checkbox as true. Here is the URL I am currently using for my button: /{!Case.Id}/e?retURL=/{!Case.Id}&00N11000004Dwmh=1&save=1

This opens the edit page but does not mark the checkbox as true. Is there a way to do this without opening the edit page? 

Example

Folks,


In the Salesforce Lightning Design System portal, show an example of a toast usage as per link below:

https://www.lightningdesignsystem.com/components/toast/


I used this example as the basis for setting it up in an environment.
The environment is configured as described below:

I have an object, called Alert, where the user can include as many alerts as he wants.
Each record of the object is an alert.

Fields of the Alert__c object:

- Name (Alert ID)
- Alert_Type__c (Example: Success, Info, Error, Warning) - User selects the type of alert you want to display
- Alert1__c (Alert message to be displayed)

 

-------------------------------------------------------------------------------

 

I created a component to display the alert on a certain page as per the code below:

 

Alert.cmp
-----------------


<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,lightning:backgroundUtilityItem" access="GLOBAL" controller="AlertController">   

    
<aura:attribute name="html" type="List" />
    
    
<aura:attribute name="showToast" type="boolean" default="false"/>
    
<aura:attribute name="Alert" type="Alert__c" default="{'sobjectType': 'Alert__c',
                         'Tipo_de_Alerta__c': '',
                         'Name': '',
                         'Alerta1__c': ''
                          }"/>
    
    
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    
<aura:if isTrue="{!v.showToast}">
    
           <aura:iteration items="{!v.html}" var="lista">        
					<div class="demo-only" style="height: 4rem;">
		
   							 <div class="slds-notify_container slds-is-relative">    
				
        							<div aura:id="alerta" role="status"> 
                                 
                                 <!--  <div id="{!Lista.Name}" role="status">   -->
													<div  class="slds-notify__content">
                            
                                                                <h2 class="slds-text-heading_small ">                
                                                                     <aura:unescapedHtml value="{!lista.Alerta1__c}" />  
                                                                </h2>
                            
                                                    <lightning:buttonIcon iconName="utility:close" variant="bare" alternativeText="Close"
                                                     iconClass="{!v.type == 'warning' ? 'light' : 'dark'}" size="small"
                                                     class="slds-button slds-button_icon slds-notify__close slds-button_icon-inverse"
                                                     onclick="{!c.close}"/>      
    
													</div>
									</div>
							</div>
					</div>
			</aura:iteration>
    
    
    
    
   

</aura:if>
    
    
    
</aura:component>

AlertController.js
-----------------------





({


   doInit : function(component, event, helper)
    {

  var action = component.get( "c.getMsgs" );

         action.setCallback(this, function(response) 
                           {                               
                             
                               var state = response.getState();

                               if(state == 'SUCCESS')
                               {                                   
                                   var alertMsgList = response.getReturnValue();
                                   var lista = [ ];                                  
                                   
                                   
                                   if(alertMsgList.length > 0)
                                   {                                       
                                       component.set("v.showToast", true);                             
                                   }
                                 
                                   
                                   
                                   for(var i = 0; i < alertMsgList.length; i ++) 
                                   {                                       
                                     
                                       /*
                                       var alerta = alertMsgList[ i ].Alerta1__c;
                                       var tipo = alertMsgList[ i ].Tipo_de_Alerta__c;
                                       var titulo = alertMsgList[ i ].Name;                                       
                                       */
                                       
                                      lista.push(alertMsgList[i]);

      						       }
                                   
                                   
                                   component.set("v.html",lista);
                                 
                                   var tipoAlerta = component.find( "alerta" );
                                   
                                   
                              //     var tipoAlerta = document.getElementById("!v.Alert.Name");
                              
                                                                      
                                              $A.util.addClass( tipoAlerta, "slds-notify" );
                                              $A.util.addClass( tipoAlerta, "slds-notify_toast" );  
                                              $A.util.addClass( tipoAlerta, "slds-theme_success" );  
   
                                   
     }
                               
               
                          else {
                                   console.log("Failed with state: " + state);
                               }
                           }); 
        
        
        $A.enqueueAction(action);
        
  
        
    },

   
    
   close: function(cmp, event, helper) 
    {
   $A.util.addClass(cmp.find('alerta'), "slds-hide");
    //  $A.util.addClass(document.getElementById('{!v.lista.Name}'), "slds-hide");
    },
   
   
       
    
})

AlertController.apxc
-------------------------------------




public class AlertController {
    
    
       
    
 @AuraEnabled
    public static List<Alert__c> getMsgs() {
        
        List<Alert__c> lst = new List<Alert__c>();
        lst = [select Tipo_de_Alerta__c, Name, Alert_Style__c,  Alerta1__c from Alert__c where Data_inicial__c <= :system.now() and Data_final__c >= :system.now()];
        return lst;
    }
    

    
}

What happens is that for every alert found, it needs to display it according to its characteristics:
- Type of alert
- Identification of each alert (For each alert, your type configuration and the close button will be checked)
- Alert message: This setting is the only one that is working, need to interact for each alert by formatting your type to receive the appropriate CSS and the close button for it.

In the Controller.js I put the part that configures the CSS and the separate close button just to test its operation, so it works only for one record, I need to put it to work in each interaction and to each of the records that are found .
That's what I can not do, if anyone can help me, I'll be very grateful.
Thank you
Hi All,
Hi All,
        i have a batch in which i am creating a parent child account hierarchy. i created new Accounts for each opportunity  And Opportunity has parent Account as the new Account which is just created and the newAccount has the Old Account as a parent.now at this time when i am executing the batch for opportunity with exact same name its creating two Accounts for each opportunity but i want that opportunity with same name should go to the account which is first created . and Opportunity should not create two Accounts .it should not created duplicate records of Account for opportunity with same name.
and if opportunity name does not contains ':'(Coloun) and '-'(Hyphen) than a checkbox Called not Processed should be true
My batch is given below:-
public class BatchResellerPartnerToResellerCustomer implements Database.Batchable<sObject>{
    //Run method to check the Batch on one record
    public static void run( Set<Id> OppIds ) {
         List<Opportunity> OppRecords =  [SELECT Name, AccountId, 
                                         Account.Name, Account.OwnerId,
                                         Account.RecordTypeId, Account.RecordType.Name  
                                         FROM Opportunity 
                                         WHERE AccountId != null 
                                         AND Account.RecordType.Name = 'Time Rack'
                                         AND Account.Customer_Type__c = 'Reseller'
                                         AND Id IN:  OppIds ];
        
        executeHelper( OppRecords );                  
    }
    public Database.querylocator start(Database.BatchableContext BC){
        String query = 'SELECT Name, Account.Name, Account.OwnerId, AccountId, '+
            'Account.RecordTypeId, Account.RecordType.Name '+
            'FROM Opportunity '+
            'WHERE AccountId != null '+
            'AND Account.RecordType.Name = \'Time Rack\''+
            'AND Account.Customer_Type__c = \'Reseller\'';
        return Database.getQueryLocator(query);            
    }
    public void execute(Database.BatchableContext BC, List<Opportunity> opportunities ){
         executeHelper( opportunities );
    }
    //Helper method to create  respective Accounts of opportunities
    public static void executeHelper( List<Opportunity> opportunities ) {
        List<Account> accList = new List<Account>();
        List<Opportunity> opptyListToBeUpdated = new List<Opportunity>();
        //Create Accounts with Opportunity's EndUser Name and ParentId with Opp's accountId
       /* Map<String,Opportunity> mapOppNameToOpportunity = new Map<String,Opportunity>();
        for( Opportunity opp : opportunities ){
            mapOppNameToOpportunity.put(opp.Name, opp);
         }*/
         for(Opportunity Oppty :opportunities  ) {
             String oppName = '';
             //Condition to get the end user name from opp name and give it to the new Account
            if(Oppty.Name.startsWith(Oppty.Account.Name)){
                oppName = Oppty.Name.removeStart(Oppty.Account.Name);
                oppName = oppName.trim();
                 if(oppName.startsWith(':') ){
                    oppName = oppName.substringAfter(':');
                    oppName = oppName.trim();
                }
                else if( oppName.startsWith('-') ){
                    oppName = oppName.substringAfter('-');
                    oppName = oppName.trim();
                }
                else{
                    oppName = Oppty.Name;
                }
                if (Oppty.Name.containsNone(':')||oppName.containsNone('-')){
                   Oppty.Not_Processed__c = True;
                }
            }
            //Condition to check opportunity has account with record type
            if(oppName != '' 
               && Oppty.AccountId != Null
               && Oppty.Account.RecordTypeId != Null){
                   //create new Account for each opportunity with customerType -'End user'
                 Account acc = new Account(Parentid = Oppty.AccountId,
                                            Customer_Type__c = 'End User',
                                            RecordTypeId = Oppty.Account.RecordTypeId,
                                            OwnerId = Oppty.Account.OwnerId,
                                            Name = oppName );
                accList.add(acc);
            }
            
         }
        if(accList.size() >0) {
            insert accList;
        }
       /* Map<String,Account> mapAccountNameToAccount = new Map<String,Account>();
        for(Account acc :accList){
            mapAccountNameToAccount.put(acc.Name, acc);
        }*/
         // Update Oppty List with newAccountId
        for(Account acc : accList) {
            for(Opportunity oppty : opportunities ) {
                /*if(mapAccountNameToAccount.containsKey(acc.Name)){
                    oppty.AccountId = mapAccountNameToAccount.get(acc.Name).id;
                }*/
               if(oppty.AccountId == acc.ParentId) {
                    oppty.AccountId = acc.Id;
                    opptyListToBeUpdated.add(oppty);
                 }
            }
        }
        if(opptyListToBeUpdated.size()>0) {
            update opptyListToBeUpdated;
        }
    }
    public void finish(Database.BatchableContext BC){
    }
}
how to prevent duplicate accounts.
Any suggestions?

We are developing a React Native App with Expo using Auth2 User Agent Flow (https://help.salesforce.com/articleView?id=remoteaccess_oauth_user_agent_flow.htm&type=0)

I have checked all different post about this topic but I still cannot receive it.

  1. Managed App > Scope > Perform requests on your behalf at any time (refresh_token, offline_access) enabled
  2. Managed App > Scope > Full Access (full) enabled

This is what we send 

https://login.salesforce.com/services/oauth2/authorize
?response_type=token
&client_id=OurCustomerKeyFromTheOrg
&redirect_uri=https%3A%2F%2Fauth.expo.io%2F%40robertovg_pve%2FprecursiveMobile

We receive all data (access_token, instance_url,..) but no refresh_token.

Reading official doc, we have added scope=refresh_token / scope=full%20refresh_token  but the response we have is that "refresh_token" is not a valid scope.

Also, we changed redirectUrl as https://login.salesforce.com/services/oauth2/success but then, how can we redirect back to the app? Putting this url, it gets stuck on the browser after putting credentials

What we missed? What else we can try? Thanks in advance.

Hi !

I'am trying to make a callout to a remote site api. This api is called with the url https://api.insee.fr/entreprises/sirene/V3/siren and the method GET.

I played with this api using RESTer and POSTMAN and it's worked fine. When I implemented it with APEX, the call systematically returns 405 Method Not Allowed.  I'm using the right URL and method but it keeps this answer. The site is allowed as a remote site.

Here is some APEX :
 
public static HTTPResponse HttpCall(String endpoint, String protocol, Map<String, String> mapHeaders, String strBody, Integer timeout)
    {
            HttpRequest req = new HttpRequest();
            req.setEndpoint(endpoint);
            req.setMethod(protocol);

        	if(timeout!= null)
                req.setTimeout(timeout); 
            
            if(mapHeaders != null)
                for(String headerkey : mapHeaders.keyset())
                    req.setHeader(headerkey, mapHeaders.get(headerkey));        
            
            if(strBody != null)
                req.setBody(strBody);
            
            system.debug(req);
            Http http = new Http();
            return http.send(req);
    }

    public static void queryBySiren()
    {        
        system.debug('QUERY BY SIREN:');
		String endpoint = 'https://api.insee.fr/entreprises/sirene/V3/siren';
		String protocol = 'GET';
		Map<String, String> headers = new Map<String, String>();
        String body = '';
        Integer timeout = 50000;
        HTTPResponse resp = SireneRequest.HttpCall(endpoint, protocol, headers, body, timeout);
        
        system.assert('OK' == resp.getStatus(), 'Request error : ' + resp.getstatusCode() + ' ' + resp.getStatus());
    }
Because it's working on RESTer and POSTMAN i'am a litle bit confused.

PS : Instead of returning 405 the api should return 401. Obviously i didn't enter credentials for some reasons ;)
Hi All,

I am trying to insert a new document into the Salesforce system referring https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm.

Getting the below error 
[
    {
        "message": "Premature end of input.",
        "errorCode": "JSON_PARSER_ERROR"
    }
]

Input

 
curl -X POST \
  https://company.cs15.my.salesforce.com/services/data/v41.0/sobjects/Document/ \
  -H 'Authorization: OAuth 00De000000........' \
  -H 'Content-Type: multipart/form-data; boundary=boundary_string' \
  -H 'Postman-Token: 0ce6bc42-75a3-45b2-b4d1-03cae18be8b4' \
  -H 'cache-control: no-cache' \
  -d '--boundary_string
Content-Disposition: form-data; name="entity_document";
Content-Type: application/json
{  
    "Description" : "Marketing brochure for Q1 2011",
    "Keywords" : "marketing,sales,update",
    "FolderId" : "00l39000001uYvs",
    "Name" : "Marketing Brochure Q1",
    "Type" : "pdf"
}

--boundary_string
Content-Type: application/pdf
Content-Disposition: form-data; name="Body"; filename="2011Q1MktgBrochure.pdf"

JVBERi0xLjcKCjQgMCBvYmoKPDwKL0ZpbHRlciAvRmxhdGVEZWNvZGUKL0xlbmd0aCA1
NjgKPj4Kc3RyZWFtCnicdVU7jt0wDOx9CtcBRIikfjzGVjnAAkmKvADJ/YsMLUuyn5Ot
tEOLGg4.........iAwIFIKL1Jvb3QgMSAwIFIKL1NpemUgNwo+PgpzdGFy
dHhyZWYKMTEyNgolJUVPRgo=
 
--boundary_string--'

Postman service Image
 
component code:
<aura:component >    
    <aura:attribute name="options" type="List" default="[
                                                        {'label': 'Mobile', 'value': 'Mobile'},
                                                        {'label': 'Laptop', 'value': 'Laptop'},
                                                        {'label': 'Hardware', 'value': 'Hardware'},
                                                        {'label': 'Software', 'value': 'Software'},
                                                        {'label': 'TV', 'value': 'TV'},
                                                        {'label': 'Cars', 'value': 'Cars'}
                                                        ]"/>
    <aura:attribute name="select" type="List" default="option1"/>
    
    <aura:attribute name="addItems" type="List"/>
    <aura:attribute name="selectedAddItems" type="List"/>
    <div class="flex-container">
        <div class="border">
            <lightning:checkboxGroup name="unSelected"
                                     label="Unselected Items"
                                     options="{! v.options }"
                                     value="{! v.select }"
                                     onchange="{! c.handleChange1 }"/>
        </div>
        
        <lightning:button label="Add" onclick="{!c.addValue}"/>
        
        <lightning:button label="Remove" onclick="{!c.removeValue}"/>
        
        <div>
            <lightning:checkboxGroup name="selected"
                                     label="Selected Items"
                                     options="{!v.addItems}"
                                     value="{!v.selectedAddItems}"
                                     onchange="{!c.handleChange2}"/>
        </div>
    </div>
</aura:component>

controller code:
({
    // var itemarray:[];
    handleChange1: function (cmp, event)
    {
     // This will contain the string of the "value" attribute of the selected option
     var selectedOptionValue = event.getParam("value");
     //var shw = 
     //alert('selected value list'+selectedOptionValue.indexOf());
     
    },
    
    addValue : function(component, event, helper) 
    {
     // get all value from the list
     
     var clearitems = component.get("v.options");
     
     // get all selected value from the list
     var gtckboxValue = component.get("v.select");
     //alert('selected value list'+gtckboxValue.length);
     var itemsArray=[];
    
     var j=0;
     for(var i=0 ; i< gtckboxValue.length; i++){
         j++;
         itemsArray.push({
             label: gtckboxValue[i],
             value: gtckboxValue[i]
         });
         clearitems.splice(i,1);
         
         // component.set("v.options",clearitems);
         // component.set("v.addItems",itemsArray);
         /*var index = gtckboxValue.indexOf(i);
            alert('index of selected items'+index);
            if(index > -1){
                gtckboxValue.splice(index, 1);
            }*/
         
     }    
     component.set("v.addItems",itemsArray);
     //clearitems.splice(j,1);
     component.set("v.options",clearitems);
    },
    handleChange2: function (cmp, event) {
        // This will contain the string of the "value" attribute of the selected option
        var selectedOptionValue = event.getParam("value");
        alert('adffdji'+selectedOptionValue);
        
    },
    
    removeValue : function(component, event, helper) {
        var gtckboxValue = component.get("v.select");
        
    }
})
Lightning Application code:
<aura:application extends="force:slds">
    <c:MyCustom_List/>
</aura:application>

Thanks in advanced .
Hi guys,

I am building a new Lightining Component and need help, please. I have two columns in my main page. I have an Object called: Produtos__c. The left column needs show all Produtos__c.Category__c from the database (DONE). When the user to click in some category, I need show all records with the category clicked by user in right column (NEED HELP).

Something like this:
User-added image
As saw, all products are being shown.

Project details:

InfoSalesMain.cmp
<aura:component controller="InfoSalesController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction,lightning:isUrlAddressable" access="global" > 
    
    <aura:handler name="init" value="this" action="{!c.doInit}" />
    
    <aura:attribute name="idProduto" type="String" />
    <aura:attribute name="DetalheProduto" type="Boolean" default="false" />
    <aura:attribute name="Name" type="String"/>
    <aura:attribute name="listaProduto" type="List" default="[]"/>
    <aura:attribute name="listaProdutoCategoria" type="List" default="[]"/>
    <aura:attribute name="listaProdutoByCategory" type="List" default="[]"/>
    <aura:attribute name="produto" type="Object" />
    
    <div class="slds-grid slds-wrap">
        <div class="slds-size_1-of-6">
            <div class="slds-box slds-theme_default">
                Bem-vindo, {!v.Name}
                <br /><br />
                <b>CATEGORIAS EXISTENTES</b>
                <br /><br />
                <aura:iteration items="{! v.listaProdutoCategoria }" var="produto">
                    <ul class="slds-list_horizontal">
                        <li> <a onclick="{!c.categoriaSelecionada}" href="#">{! produto.Category__c }</a> </li>
                    </ul>
                </aura:iteration>
            </div>
        </div>
        <div class="slds-size_5-of-6">
            <div class="slds-box slds-theme_default">
                <lightning:card>
                    <div class="slds-p-left_medium slds-p-right_medium">
                        <ul class="slds-list_vertical slds-has-dividers_top-space">
                            <aura:iteration items="{! v.listaProduto }" var="produto" >
                                <!-- Activate the next line when discovered how get ProdutoByCategory -->
                                <!-- <aura:iteration items="{! v.listaProdutoByCategory }" var="produto" > -->
                                <li class="slds-list__item">
                                    <!-- Here will be the produto image -->
                                    <lightning:avatar size="large" src="/docs/component-library/app/images/examples/avatar2.jpg" initials="CR" fallbackIconName="standard:person_account" alternativeText="Cindy Rice" class="slds-m-right_small"/>
                                    <b>Descrição: </b> {! produto.Description__c }<br/>
                                    <b>Preço:</b> R$ {! produto.Price__c }
                                </li>
                            </aura:iteration>
                        </ul>
                    </div>
                </lightning:card>
            </div>
        </div>
    </div>
    <!-- NEXT SCREEN IS NOT COMPLETE -->
    <aura:if isTrue="{! v.DetalheProduto }">
        <c:DetalheProduto idProduto="{! v.idProduto }"/> 
    </aura:if>
</aura:component>
InfoSalesController.apxc
public class InfoSalesController {
    
    @AuraEnabled
    public static String saveProduto_CTRL(String jsonProduto){
        Produto__c produto = (Produto__c) Json.deserialize(jsonProduto, Produto__c.class);        
        UPSERT produto;
        return 'Produto inserido com sucesso';   
    }
    
    @AuraEnabled
    public static Produto__c getProdutoSObj(){
        Produto__c prod = [SELECT Id, Capacidade__c, Category__c, Description__c, Foto__c, Frequencia__c, Inches__c, Price__c, Socket__c, Storage__c FROM Produto__c];
        return prod;
    }
    
    @AuraEnabled
    public static String deleteProduto_CTRL(String jsonProduto){
        
        Produto__c produto = (Produto__c) Json.deserialize(jsonProduto, Produto__c.class);
        delete produto;
        return 'Produto excluído com sucesso';
    }
    
    @AuraEnabled
    public static List<Produto__c> getListProduto_CTRL(){
        List<Produto__c> listReturnProd = [SELECT Id, Description__c, Foto__c, Price__c, Category__c FROM Produto__c];
        listReturnProd.sort();
        System.debug('listReturnProd: '+listReturnProd);
        return listReturnProd;       
    }
    
    @AuraEnabled
    public static List<AggregateResult> getProdutoCategory_CTRL(){
        List<AggregateResult> listReturnCategoryProd =[SELECT Category__c FROM Produto__c GROUP BY Category__c ORDER BY Category__c ASC];
        return listReturnCategoryProd;
    }
    
    @AuraEnabled
    public static List<Produto__c> getProdutoByCategory_CTRL(String paramCtgSelecionada){
        List<Produto__c> listReturnProdutoByCategory = [SELECT Id, Description__c, Foto__c, Price__c, Category__c FROM Produto__c WHERE Category__c =: paramCtgSelecionada];
        return listReturnProdutoByCategory;
    }
    
    @AuraEnabled
    public static String getUserName() {
        return userinfo.getName();
    }
    
}
InfoSalesMainController.js
({
 	doInit: function(component, event, helper) {
        helper.getUser(component);
        helper.getProdutos(component);
        helper.getCategoriaProduto(component);
    },
    categoriaSelecionada : function(component, event, helper) {
    	//helper.getCategoriaSelecionada(component);
    	var src = event.getSource();
        var name = src.get("v.value");
        component.set("listaProdutoByCategory",name);
    }
})
InfoSalesMainHelper.js
({
    getUser : function(component){
        var action = component.get("c.getUserName");
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.Name", response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    },
    getProdutos : function(component) {
        var action = component.get("c.getListProduto_CTRL");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set('v.listaProduto', response.getReturnValue());
            } else if (state === "ERROR") {
                alert('Erro: Lista vazia');
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    getCategoriaProduto : function(component) {
        var action = component.get("c.getProdutoCategory_CTRL");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set('v.listaProdutoCategoria', response.getReturnValue());
            } else if (state === "ERROR") {
                alert('Erro: Lista vazia');
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    
	getCategoriaSelecionada : function(component) {
        var action = component.get("c.getProdutoByCategory_CTRL");
        action.setParams({ 
            paramCtgSelecionada : component.get("v.categoriaClicada")//How to pass this variable to apex?
        });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set('v.listaProdutoByCategory', response.getReturnValue());
            } else if (state === "ERROR") {
                alert('Erro: Lista vazia');
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
        });
        $A.enqueueAction(action);
    }
    
})
What I need to do? What I am forgetting?
Hi all,

I need help figuring out why my visual flow is failing.  Here is the email error information:

Flow Interview Details
Interview Label: Sharing Contact with Breakthrough Role Associated BT Site 2/28/2018 11:37 AM
Current User: Holly Havelka (00533000004LpP0)
Start time: 2/28/2018 11:37 AM
Duration: 0 seconds

How the Interview Started
Holly Havelka (00533000004LpP0) started the flow interview.
Some of this flow's variables were set when the interview started.
varAssociatedBTSiteName = Atlanta
varAssociatedContact = 0031D000003HipNQAS

RECORD QUERY: Lookup_Associated_BT_Site_Role_ID
Find one UserRole record where:
DeveloperName Equals {!varAssociatedBTSiteName} (Atlanta)
Result
Successfully found record.
{!varAssociatedAffiliateSite} = 00E40000000kkg8EAA

RECORD CREATE: Share_Contact_Record_with_Associated_Affiliate_Site
Create one ContactShare record where:
ContactAccessLevel = Read
ContactId = {!varAssociatedContact} (0031D000003HipNQAS)
RowCause = Manual
UserOrGroupId = {!varAssociatedAffiliateSite} (00E40000000kkg8EAA)
Result
Failed to create record.

Error Occurred: This error occurred when the flow tried to create records: FIELD_INTEGRITY_EXCEPTION: User/Group ID: id value of incorrect type: 00E40000000kkg8EAA.
Hi

on my last stage of opportunity, i have 2 checkboxes  
one closed won 
one closed loss
how can i manage to update the probability field in accordance to the checkboxes ? 
if the sales person check closed loss , i want the probabilty to switch to 0% 

 
I had my actual Gmail on Webassessor.com. I am doing Trailhead using Myname@companyname.com(not Actual email just a login name). But I verified Myname@companyname.com account using actual Gmail id(Which  I use on Webassessor).  So, I have question

1. Whatever I will complete on  Myname@companyname.com trailhead then It must show on my webassessor account then What I have to do.
2. Before using Myname@companyname account, I had done many badges using an old Email address which is not exist so can I merge that account on here.
Challenge Not yet complete... here's what's wrong: 
The BoatSearchResults JavaScript controller doesn't call the correct method. The controller must call helper.onSearch(), passing the component.


Anyone Completed this step Please help me with the Answer.
Hello, 

I have a formula that produces an outcome of either YES or NO. 

This formula will produce a NO if any of the selections are made. 

A YES would be produced if additional picklist items are selected (not shown). 

What i'm trying to do, is somehow make this formula shorter if possible? 

Would anyone know how to condense it? 

thanks!

 
IF(
OR(
AND(
NOT(ISPICKVAL([Account].productA, "")),
NOT(ISPICKVAL([Account].productA, "No Location"))
),
AND(
NOT(ISPICKVAL([Account].productAB, "")),
NOT(ISPICKVAL([Account].productAB, "No Location"))
),
AND(
NOT(ISPICKVAL([Account].productXY , "")),
NOT(ISPICKVAL([Account].productXY , "No Location"))
),
AND(
NOT(ISPICKVAL([Account].productEE, "")),
NOT(ISPICKVAL([Account].productEE, "No Location"))
)
), "Yes", "No")

 
This might be simple but I am unable to figure out what I am missing. I need to get Project Managers from the VF page and pass them in to my Query. Here is my Apex class and my VF page.
Class :
public class ProjectsFilterByDates{
public ProjectsFilterByDates(ApexPages.StandardController stdController) {
  }
  Date StartDate;
  Date EndDate;
  public String DateStringProperty{get;set;}  
  List<AcctSeed__Project__c> results;
  String[] ProjectManagers = new String[]{};
  public Date getstartDate(){
  return StartDate;
  }
  public Date getEndDate(){
  return EndDate;
  }
  Public List<AcctSeed__Project__c> getresults(){
  return results;
  }
  public void setStartDate(Date input){
  StartDate = input;
  }
  public void setEndDate(Date input1){
  EndDate = input1;
  }
  
     public List<SelectOption> getListOfUser(){
     List<User> Users = [select Name from user Where Project_Manager__c = true Order By Name ASC] ;
     List<SelectOption> options = new List<SelectOption>();
        for(User u : Users)
               {
                options.add(new SelectOption(u.Id , u.Name));
               }
                  return options;
                  }
  public String[] getProjectManagers (){
  return ProjectManagers;
  }
  public void setProjectManagers (string[] ProjectManagers){
  this.ProjectManagers = ProjectManagers;
  }   

  public PageReference Search(){
  results = [SELECT Name,UserID__c,AcctSeed__Account__r.Name,Date_Created__c,Construction_Manager__r.Name,AcctSeedERP__Manufactured_Product__r.Name,Project_Manager__c FROM AcctSeed__Project__c WHERE Date_Created__c >= :StartDate AND Date_Created__c <= :EndDate AND Project_Manager__c =:ProjectManagers order by Date_Created__c desc ];
  return null;
  }
}
VF Page:
<apex:page Standardcontroller="AcctSeed__Project__c" extensions="ProjectsFilterByDates" showHeader="false" sidebar="false" docType="html-5.0" language="en_Us" >
<apex:form >
<apex:pageBlock >
 Start Date: <apex:input type="date" value="{!StartDate}"/>
 End Date: <apex:input type="date" value="{!EndDate}"/>
<apex:selectList value="{!ProjectManagers}" size="5" multiselect="true">
<apex:selectOptions value="{!ListOfUser}"/>
</apex:selectList><p/>

<apex:commandButton value="Search For Projects" action="{!search}"/>
<apex:pageBlockTable value="{!results}" var="p">
<apex:column value="{!p.Name}"/>
<apex:column value="{!p.AcctSeed__Account__r.Name}"/>
<apex:column value="{!p.Project_Manager__c}"/>
<apex:column value="{!p.Date_Created__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
In My Existing VF code I’ve related list "Notes&Attachments" tied to Account
  <apex:relatedList subject="{!account}" list="NotesAndAttachments"   />  

Now i want to replace with Files and Notes.
     <apex:relatedList subject="{!account}" list="AttachedContentDocuments"  />   
      <apex:relatedList subject="{!account}" list="AttachedContentNotes"  />

Issues is with Notes - I’ve to set the API version above 35 in order to identify AttachedContentNotes object. If i do that, I’ll lose access to existing Notes&Attachment on VF Page, since above 36 version are not supported to notes and attachment.

How can i display both Notes&Attachment and AttachedContentNotes ? or what will be an ideal solution, the reason i want Note&Attachments is it has all historical data and other integration ties

Please Suggest,
Thanks In Advance
  • October 27, 2016
  • Like
  • 1
Hi All,

Am facing this issue on step 5 , can any one help me complete this challenge.

User-added image
Hi Team,
Object:Account
CustomFields in account:Birthdate , SerialNo(unique one).
UseCase:
I have a requirement to Create and share a api from Salesforce to the client that,
When the user enters the accountname, birthdate and serialNo, if the data is there then we need to send  response that "Record Found" else  "Record not found in response".
Any links or documents to go through it.
        As iam new to Integration, can any one plase help me out for this requirement.

Thanks
Sfdx 
 
We are getting the following error message but don't understand why:

The Salesforce to Salesforce operation from [Org1] to [Org2] failed because the Rate limit either in [Org1] or [Org2] was exceeded. Error Message : CODE - REQUEST_LIMIT_EXCEEDED Message - ConcurrentPerOrgLongTxn Limit exceeded.. We'll retry the operation in an hour. If more attempts are needed, they'll take place 2, 4, 8, and 16 hours after the previous retry.

We checked our API calls and both orgs are under 50%. What does this error mean and how can we prevent it?
I am trying to deploy a lightning flow from a dev sandbox to a fullsandbox. Both are running the most up to date version SFDC. The deployment is failing and I'm getting the following error message: 


Because the TriggerType field has the value "RecordBeforeSave", you also need to set the following fields: SaveType.

I'm unsure how to set "SaveType" in a flow. 
I created the following validation rule: 

ISCHANGED(Lead_Source_INTL__c) &&
NOT(ISBLANK(PRIORVALUE(Lead_Source_INTL__c))) &&
$Profile.Name <> 'System Administrator' &&
$Profile.Name <> 'Sales Support' &&
$Profile.Name <> 'API User' &&
$Profile.Name <> 'Marketing Administrator' &&
NOT(BEGINS($User.Username, 'giselle.petit@intlfcstone.com'))

However, I cannot deploy it because the class below is failing:

static testMethod void ShouldNotAllowCustomStandardUserToUpdateLeadSource() {
        User u = [SELECT Id FROM User WHERE IsActive = true AND ProfileId = :sObjectCreator.customStandardUserProfileId LIMIT 1];
        Boolean hasValidationError = insertAndUpdateLeadSourceAsUser(u);
        System.assert(hasValidationError);

Unfortunately, my only developer is on vacation :(  and I am not sure what is going on. Please help!
 
I've taken over our org from the previous dev and even though I'm not a developer (I'm the admin) I need to fix this issue. I have limited dev experience but I figured I'll give this a shot.
We are using lightning components for our opportunities. We also have a few custom fields on the page layout as well in addition to the lightning component. 
The lightning component has a custom button that changes the stages of the opportunity. 
I would like to add a line of code to that button that will also change the value of one of the custom picklists. This picklist does not exist in the lightning component - it's just a custom field on the layout itself. 
The button click action is on the ComponentHelper.js so I'm adding the line there but I'm having issues.
The custom field is Demo_Audit_Status__c so I thought the line of code would be:
component.set("Demo_Audit_Status__c", "No Demo Needed");
I'm pretty sure I'm oversimplifying what I need but I'd rather fix this before having to reach out to the original devs.
I need urgent help.I want to use snapchat in salesforce.com for sending messages I have searched on this but i have gotten information only about snap-ins,snap logic. Is it same to snapchat or not?.Please give information on this and also tell me how to integrate snapchat into salesforce.
I got stuck here, can someone help to slove this error,
below my code,
Trigger:
trigger Level2Update on Account_Case_Escalation__c (after update) {

for(Account_Case_Escalation__c ACE: trigger.new)
{
util.callwebservice(ace.Account__c, ace.Level_2_Name__c, ace.Level_2_Email__c, ace.L2_Title__c);
system.debug('Account Case account  '+ ace.Account__c);
system.debug('Account Case email  '+ ace.Level_2_Email__c);
system.debug('Account Case name  '+ ace.Level_2_Name__c);
system.debug('Account Case Title  '+ ace.L2_Title__c);


}

}

Apex Class:

public with sharing class util
{
@future(callout=true)
public static  void callwebservice(Id Accid, String name, String email, String title)

{
HTTP auth = new HTTP()    ;
//List<contact> acc = [Select Id, Name from Account Where Id IN :recordIds];
//String Body = "Accountid":cid + "id":aid;

HTTPRequest r = new HTTPRequest();
r.setHeader('Content-Type','application/json');
String username = 'appviewxsupport2@yopmail.com';
String password = 'Appviewx@123';

Blob headerValue = Blob.valueOf(username+ ':' + password );
String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
r.setHeader('Authorization', authorizationHeader);
r.setEndpoint('https://salesforceintegrationstaging.payoda.com/api/web/v1/accounts/updateaccountdetails');
r.setMethod('POST');
r.setBody('{"account_id":"accid","level_2_name":"name","level_2_email":"email","level_2_title":"title"}');
//r.setBody(body);   
HTTPResponse authresp=new HttpResponse();
authresp = auth.send(r);
system.debug('Statuscode Expected'+ authresp.getStatusCode());
System.debug('Body expected' + authresp.getBody());
}
}

When I run the above code below the error i facing,
Error: System.HttpResponse[Status=Unauthorized, StatusCode=401

TIA
 
Hi, 
I am struggling with sending a REST Callout from one Salesforce org to another. I am not able to get the access token. Here is my code snippet - 
** Callback url in the connected app on target org - https://<domainName>.my.salesforce.com/services/oauth2/token


String clientId = 'consumer key  from the connected app in the target org';
String clientSecret = 'consumer secret from the connected app in the target org';
String username = 'my username in the target org';
String password = 'my password in the target org';

HttpRequest req = new HttpRequest();
Http h = new Http();
String reqbody = 'grant_type=password&client_id='+ clientId + '&client_secret='+clientSecret + '&username=' + username + '&password='+ password;
req.setMethod('POST'); 
req.setEndpoint('https://test.salesforce.com/services/oauth2/token'); 
HttpResponse res = h.send(req); 
System.debug(res.getBody()); 
deserializeResponse der = (deserializeResponse) JSON.deserialize(res.getBody(), deserializeResponse.class);
String accessToken = der.access_token;
**** I get an error Here - {"error":"invalid_grant","error_description":"authentication failure"}

HttpRequest req2 = new HttpRequest(); 
req2.setEndpoint('https://<domainName>.my.salesforce.com/services/apexrest/<RestResourceClassName>/<HttpPost method name>'); 
req2.setHeader('Authorization','Bearer ' + accessToken); 
req2.setHeader('Content-Type', 'application/json');
req2.setMethod('POST'); 
req2.setBody( body ); 
Http h2 = new Http(); 
HttpResponse res2 = h2.send(req2);
**** Second callout error is as a result of null access token i believe  - [{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]
 
  • March 31, 2019
  • Like
  • 0
I've been searching all over for help on creating a visualforce page that collects more than one contact and more than one contact type.  
If anyone could help it would be most appreciated.

Requirements:
- One form that captures multiple contacts to populate the Contact Object
- Two Record Types (Contact Record Type and Student Record Type)
- Ability to click a button that says "Add Additional Family Member" in both areas 
- MailingState field is a picklist of all US States

More Details:
  • Instance is using Nonprofit Edition/Households.
  • Each time a new contact is created, it is automatically marked the 'primary contact' and SF is creating a new "Household Account" on the Account object. 
  • The form is collecting 'family' or 'household' data.  Which means at least one adult and one kiddo but it could also mean two adults and 4 kiddos.  The adults have a record type and the kiddos have a record type.
  • For the adults: the form only has 6 fields (first name, last name, email address, mailing city, mailing state and mailing zip).  But the mailing state has to be a picklist of US States.
  • For the students: the form only has 5 fields (first name, last name, current grade, today's date, and school attended)

This is all I have right now:
<apex:page standardController="Contact" Sidebar="False">
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >
          <apex:inputField value="{! Contact.FirstName }"/>
          <apex:inputField value="{! Contact.LastName}"/>        
          <apex:inputField value="{! Contact.Email }"/>  
          <apex:inputField value="{! Contact.MailingCity }"/>  
          <apex:inputField value="{! Contact.MailingPostalCode }"/>  
            
            <apex:commandButton action="{! save }" value="Save" />
            <apex:commandButton value="Cancel" action="{!cancel}" />    
            

            </apex:pageBlockSection>
            
    </apex:pageBlock>  

    </apex:form>
</apex:page>

 
 
 
 
window.open('/{!$Setup.SVC_Reporting_Ids__c.InterfaceReportId__c}?pv0={!Account.Id}');

Theres the button, now i'm trying to find the simplest way to get this to work in lightning, because theres 50 or so buttons like this, that i'll have to manually convert..(because the configurator doesn't want to do it).

This button is on a related list.

I can't for the life of me figure out the syntax to get it to work as a custom URL button. I'm thinking of just making a VF page to run a <script></script>. 

Would either of these be possible or am i stuck using lightning components....
Transitioning to LEx.  I go to the Accounts tab, check the Person Accounts List View - I see a record with the first name of Kate.  I go to the Case tab, click New, go to the Contact field, and lookup "Kate" - no results.

I swich to Classic (same User).  I go to the Case tab, click New, go to the Contact field, and lookup Kate.  The Contact record appears instantly.

I go back to LEx, Case, New, Contact field, lookup Kate - and now the Kate record appears.  

What's happening?  What am I doing wrong?  Why doesn't Kate appear on my first try in LEx?

thanks
chris
In My Existing VF code I’ve related list "Notes&Attachments" tied to Account
  <apex:relatedList subject="{!account}" list="NotesAndAttachments"   />  

Now i want to replace with Files and Notes.
     <apex:relatedList subject="{!account}" list="AttachedContentDocuments"  />   
      <apex:relatedList subject="{!account}" list="AttachedContentNotes"  />

Issues is with Notes - I’ve to set the API version above 35 in order to identify AttachedContentNotes object. If i do that, I’ll lose access to existing Notes&Attachment on VF Page, since above 36 version are not supported to notes and attachment.

How can i display both Notes&Attachment and AttachedContentNotes ? or what will be an ideal solution, the reason i want Note&Attachments is it has all historical data and other integration ties

Please Suggest,
Thanks In Advance
  • October 27, 2016
  • Like
  • 1