• Shri Raj
  • SMARTIE
  • 1054 Points
  • Member since 2014

  • Chatter
    Feed
  • 27
    Best Answers
  • 3
    Likes Received
  • 5
    Likes Given
  • 31
    Questions
  • 357
    Replies
TLDR; Instead of native form submission for web2lead form, I am using REST API to hit the https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8 endpoint with form data in the request body to submit the Web2Lead form. And it's getting CORS error.
---
While the raw form looks like this
 
<form action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">


I have built the form using some custom components in React and providing the below `handleSubmit` handler to it to submit the form.
const actionUrl =
    'https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';

  const handleSubmit = async (formValues) => {
    try {
      await axios.post(actionUrl, formValues, {
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
        },
      });
    } catch (error) {
      console.error(error);
    }
  };

And this axios request is getting CORS error on the browser although I added the domain to the whitelist on the security settings.
Are Web2Lead forms intended to be submitted as a native form always? Is there a way to submit this form using axios without getting the CORS error?
Hello I was wondering what was the best way to create a map of 3 related objects. Eg. The grandchild looks up to the child, the child looks up to the parent. I know that you can use dot notation to get to the Parent from the grandchild, but was needing to go from the Top down. Would like to associate a key pair if possible

How to write test class for map<object,object>collection object please have a look the below code
 @AuraEnabled
    public static String createContactRecords(List<Object> lstObjects) {
        
        For(Object obj : lstObjects) {
            Map<Object, Object> mapContact = (Map<Object,Object>)obj;
            
            If(mapContact.get('type') == 'string' || 
               mapContact.get('type') == 'text' || 
               mapContact.get('type') == 'textarea' || 
               mapContact.get('type') == 'url' || 
               mapContact.get('type') == 'phone' || 
               mapContact.get('type') == 'email'
              )  {
                  If(mapContact.get('value') != null && String.valueOf(mapContact.get('value')) != '') {
                      objContact.put(String.valueOf(mapContact.get('field')), String.valueOf(mapContact.get('value')));
                  }
              }
}





test class-
@isTest
public class ContactFormHandler_Test {
    @isTest
    public static void test(){
        Account acc= new Account();
        acc.Name = 'test';
        insert acc;
        contact con = new Contact();
        con.LastName = 'test1';
        insert con;
        List<object> objList = (List<object>)json.deserializeUntyped('[{"field": "FirstName","type": "string", "value": "tedf"},{"field":"LastName", "type":"string", "value":"hgghjh"}]');

ContactFormHandler.createContactRecords(objList);

It show error - System.TypeException: Invalid conversion from runtime type Map<String,ANY> to Map<ANY,ANY> 
     

So I have created my milestone called First Response and tried to auto complete it when I send an email to a contact associated with the account. I found a code online but does not seem to work
https://help.salesforce.com/s/articleView?id=sf.entitlements_milestones_trigger.htm&type=5
Can you help me I have copied the apex class and trigger and still nothing works
Trigger whenever a record is inserted to the account automatically insert to the contact and throw error if contact is more than 5.
Write trigger that country (custom field) field of account object  should get copied with the value of country(custom field) of contact object whenever a contact is created or account is updated

 
I am writing a trigger where every new case gets an entitlement that I created automatically. I want the same entitlement for every case even if the accounts are different. What I have done so far I have created a entitlement process and created a dummy account. I then created a new entitlment with the entitlement process and dummy account. I then put entitlement in my case layout so when I create a case I can search for the entitlment and append to any case. I want to make the entitlement stick to every case that gets generated automatically without me selecting it in my case layout. 
Hello, 

I am trying to create a rule that prevents users from checking off a checkbox if they choose specific values from a picklist. 

The picklist for our logged calls is labeled Type, and if options A or B are chosen, they should not be able to check off a custom checkbox. That checkbox should only be able to be TRUE if any of the other types have been selected. 

Can anyone help me nail this down?! Much appreciated!
Where am I going wrong?  this works if I only ask for the Owner ID but as soon as I try and get the user name I get an unknown error parsing query.

SELECT OwnerId,  User.Name FROM Event, StartDateTime,Subject,Hotel__c,Activity__c,Notes__c,    Done__c,Completed__c,Cancelled__c,Postponed__c
FROM Event
WHERE StartDateTime = LAST_MONTH

Any help much appreciated.

Thanks
Hi all I am new to the Salesforce development side and am wondering how to create a test class for the below Apex Class I have written. I understand I need to create test data in the test class, but I am not sure how to test out the last part of this class which is calling another Apex Class from a managed package that exports Contact records to a 3rd platform. Any help and guidance would be much appreciated.
global class ExportBackgroundCheckCompleteToGolden {

    @InvocableMethod(label='Export Background Check Completed Volunteers To Golden' description='Exports contacts who have completed their background check with Sterling Volunteers to Golden' category='Contact')

    public static List<Contact> BackgroundCheckCompleteToGolden(List<Contact> contacts) {

        List<Contact> exported = new List<Contact>();

        if ((contacts == null) || (contacts.size() == 0)) {

            System.debug('No contacts');

            return exported;

        } else {

            System.debug('There are ' + contacts.size() + ' contacts.');

        }

        for (Contact contact: contacts) {

            if ((contact != null) && (contact.VVSA__VV_Status__c == 'Eligible')) {

                exported.add(contact);

            }

        }

        if (exported.size() > 0) {

            goldenapp.ExportToGoldenBatch.runSyncJob(exported, 'Background Check Completed');

        }

        return exported;

    }

}

 
Hi, 

I took over support for an organization and in reviewing their previously written Apex Classes, a lot of them have this PageReference method stuck on at the end and I'm not completely sure what it is for. It's repetitive and many lines, so please forgive the longcat below.

Here's the whole method:
Public PageReference codecoverage()
    {
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        if(Test.isRunningTest()){}
        return null;
    }

The rest of the class code that is actually doing the work is contained in an if statement
 
if(!Test.isRunningTest())
        {
           // code to do work here

         }
         else
        {
            system.debug('test');
        }

Any ideas what this code structure and methods are for?
I have a Visualforce page that manages the generation, update and removal of records for annual processing of allocation processes. This is a once a year mannual process in which a user decides to delete older records (previous years), generate records for coming years or simply add records for new allocatable objects.

The controller is using the Database.batchable class to handle the rather large amount of records deleted or created in one go. This means that a simple Apex:ActionFunction to rerender the page isn't doing the trick, as the process triggered by the button is asyncronous and might complete only after several minutes.

I'm passing the controller object to the class that handles the batch calls, but I have not figured out a way to trigger via the page controller a rerendering of the page, once the batch processing is completed.

Any suggestions on how to achieve that?
Hey everyone I have a quick question I have a outputlink that looks like a button and I want it to hover when I go over it. This is my code. Thank you in advance.

<style type="text/css">
    [id*=button] {  background-color: white !important;
                    border: 1px solid black !important;
                    color: black !important;
                    text-decoration: none !important;
                    padding: 9px !important;
                    cursor: pointer !important;
 }
 [id*=button:hover] {  background-color: white !important;
                }
 [id*=wrapper] {  
                    margin: auto;
                    width: 50%;
                    text-align: center !important;
                    padding: 10px;
                    height: 100px !important;
                }
   
</style>
    <div id="wrapper">
     <apex:repeat value="{!TechnologyProduct}" var="res" >
            <apex:outputPanel rendered="{!res.Detail_Link__c != null}" layout='none'>
                    <apex:outputlink value="{!res.Detail_Link__c}" styleClass="btn" id="button"> {!res.Detailed_Product_Name__c} </apex:outputlink>                  
            </apex:outputPanel>
     </apex:repeat>
    </div>
</apex:page>
Hi just a small sample code .
 
public class TargetPlanController {    
        
    @AuraEnabled    
    public static List <TargetPlan__c > fetchAccts(Id recordId) {    
            
        return [SELECT Name,Account__c,No_of_Leads__c,AccountCity__c,FROM TargetPlan__c where BP_Id__c =: recordId ];
          }      
        
}

How to write the Test Class for the Above code.. please let me know.
Thanks 
Prathusha Reddy.
 
Hey So I have created a button where I want the !res.Detail_Link__c to be displayed in the button and I want it to go to the link when click on !res.Detail_Link__c and if there is no link the button should not be visible.

<apex:page controller="TechnologyProduct" lightningStylesheets="true">
    <apex:form>
    <apex:pageBlock>
    <apex:pageBlockSection title="Vitality Check Attributes">
            <apex:repeat value="{!TechnologyProduct}" var="res">
<apex:outputText value="{!res.Detail_Link__c}" /><br/>
       <apex:commandButton  value="{res.Detailed_Product_Name__c}"/>
            </apex:repeat>
    </apex:pageBlockSection>
         </apex:pageBlock>
        </apex:form>
</apex:page>
Hey I was able to do a SOQL and store it in a list. How do I return it and use it in my VF page. Thank you in advance

Controller:
public with sharing class TechnologyProduct {

    public TechnologyProduct() {
     List <Technology_Product__c> result = [SELECT Id, Name FROM Technology_Product__c where Account__c='00105000002oNIyAAM']; 
    }   
}
Hello,
I am debugging flow.
I am providing input values as needed, like opportunity id, but it is not getting detected.
hwhat are the popentail reasons, please
  • January 30, 2023
  • Like
  • 0
Hey I am new to visualforce. I am coding through VScode. I am able to get the particular data and show it on my sandbox and It looks fine when I put lightningStyleSheet="true". When I put the page in a site the css changes. Is this because there is a wrapper over my page that is influencing the css. If so how would I find out? Is there a way to overpower that css? How do you write css in a apex page, do you create a different style page and connect? A lot of question I know, Thanks for the help. 

This is the code:
<apex:page controller="TestQuote"  lightningStylesheets="true" showHeader="false" sidebar="false" applyBodyTag="false" applyHtmlTag="false"  >
<apex:form  >
<apex:pageBlock >
<apex:pageBlockSection >
    <apex:pageBlockSectionItem >
    <apex:outputLabel value="Quote Request Name:" for="name" ></apex:outputLabel>
    <apex:outputField value="{!result.Quote_Request__r.name}" />
    </apex:pageBlockSectionItem>  
</apex:pageBlockSection>    
</apex:pageBlock>
</apex:form>
</apex:page>
  
I have a field Next order date in contract
Written a batch class to creaet automatically order if the contract is Activated. When the Contract status is made activated at that time the Next order Date will display the immediate wednesday which is handled by flow.

I need to do an setup that when Order status will be Order Dispatched then the Next Order Date should display Order Start Date + 30 days or Order Start Date + 30 days  (immediate wednesday).

Is it possible by flow If yes then how, if no then how we can achieve this.

Thanks
Hello everyone, 
I am wondering if any best practices out there for lead scoring based on their geographical location other than creating custom formula field? 
Thanks so much in advance. 

Hi All, 

Would it be possible to have an Validation Check in place or some kind of an pop-up asking "Are You Sure" before deploying code into Server? 
Right Click on an eclipse Project --> Force.com-->Deploy to Server

Before  Deploying to server, Do we have any option in Eclipse which we can enable to precheck. I have accidentally Hit on "Deploy to Server" rather than "Refresh from Server".  

Hello,

Is there anyway out in Salesforce where we can export data in .TSV / Tab Separated Values? Can you kindly suggest some good tools from the market?

Thanks,
Shri
Can anyone share an example considering Account as an example. 

Thanks
Shri

Hello All.

 Here is the challenge which i need to implement and looking for a solution approach. 

I need to implement a custom VF Page Search Functionality inside Salesforce. The Data is inside Elastic Search which is a open source Search & Analytic engine. The Elastic Search is inside our Company's network. I have the API to access using JSON & I'm able to do it using a REST based tool. 

Now, Since Salesforce is outside our Company's network i need to authenticate using Ping Identity & then access Elastic Search API. 

I'm really not sure about how this authentication works since the first call will be from Salesforce everytime. Can someone please help. I'm unsure if this will be using SSL or OAuth etc.

Thanks, 

Shri.

Hello, 

I would like to know if there is an email notification by default which would notifies the Users when the owner of that a particular record is assigned to them? 
I see a default check box which can also be set false. But i want to keep it active. Any profile permissions? 

Thanks, 

Shri

Hello All,

I know we can upload a CSV into Salesforce using various different ways. I'm conducting a POC in my company to upload a CSV file into Salesforce using a JAVA program. Can someone please guide or provide any reference links? 

Thanks, 
Shri

There are two record Types. RT1 and RT2. And a Status picklist field based on the recordtype. 

One a VF Page, If a user only has access to RT1 then he/she is able to see only picklist values which are displayed for RT1. 
One a VF Page, If a user only has access to RT2 then he/she is able to see only picklist values which are displayed for RT2.

If i add a permission set for a Users and give access to both the RecortyTypes RT1 & RT2, On the Visualforce Page its displaying all the picklist values and not by the Recordtype of that record. 

Please guide
Shri
I'm trying to access an external System which is inside my office network. Using the POST method I will try to access the data from that system. For Eg : If i pass the zipcode, I can get the city Name. 

What all are the things i need to consider before making this call to that system apart from the EndPoint. 

Thanks
Hello, 

Can someone explain what exactly is Authentication and how does it work in Salesforce for REST & SOAP based integrations. Please mention in simple terms. 

Thanks
I'm trying to access a inhouse EndPoint in my company from Salesforce.com through HTTP POST Method. How does the Authentication work on the Salesforce side? Before accessing the End Point do i need setup anything else on the Salesforce side?  
Hello All,

I will try to frame my question in short.

End Goal : REST API Integration from Salesforce to a InHouse Lead Management System(LMS2)

SUCCESS Through Chrome APP
1.  All i need to do is retrieve values from LMS2. When i tried to use the Chrome APP 'Advanced Rest Client' and have passed the appropriate URL and Content in XML/TEST format in the form of POST methoed I was able to retrieve the values from LMS2 database.
For EG : If i pass 92126 then i was able to get 'SAN DIEGO' which is correct.

Here is the link (https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo?hl=en-US)for Advanced REST Client.


PROBLEM from Salesforce :

2) When i created this REST class in SAlesforce and tried invoking the End Point then its throwing this error.

System.HttpResponse[Status=Service Unavailable, StatusCode=503]

public with sharing class LmsRestApiIntegration {

//LmsRestApiIntegration.invokeRestAPI()
@future(callout = true)
public static void invokeRestAPI(){
String URL = 'http://pasquote-bfapp.tent.trt.ccc.pri/QuickQuoteWebSvc/QQWebSvc.asmx';
String xmlContent = '';
xmlContent = '<?xml version="1.0" encoding="utf-8"?>';
xmlContent = xmlContent + '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
xmlContent = xmlContent + '<soap:Body>';
xmlContent = xmlContent + '<GetCityListFromZip xmlns="http://www.ccc.com/irv/quickquote/auto/2006/10/01">';
xmlContent = xmlContent + '<zipcode>92126</zipcode></GetCityListFromZip>';
xmlContent = xmlContent + '</GetCityListFromZip>';
xmlContent = xmlContent + ' </soap:Body>';
xmlContent = xmlContent + '</soap:Envelope>';
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setBody(xmlContent);
req.setHeader('content-type','text/xml');
req.setHeader('content-length', '0');
req.setEndpoint(URL);
req.setHeader('SoapAction', 'http://www.ccc.com//irv/quickquote/auto/2006/10/01/GetCityListFromZip');
req.setMethod('POST');
String response = '' ;
HttpResponse res = h.send(req);
response = res.getBody();

System.debug('Response :'+response);

}
}

Please guide.

Thank You
Shri
Hello All,

I will try to frame my question in short.

End Goal : REST API Integration from Salesforce to a InHouse Lead Management System(LMS2)

SUCCESS Through Chrome APP
1.  All i need to do is retrieve values from LMS2. When i tried to use the Chrome APP 'Advanced Rest Client' and have passed the appropriate URL and Content in XML/TEST format in the form of POST methoed I was able to retrieve the values from LMS2 database.
For EG : If i pass 92126 then i was able to get 'SAN DIEGO' which is correct. 

Here is the link (https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo?hl=en-US)for Advanced REST Client.


PROBLEM from Salesforce :

2) When i created this REST class in SAlesforce and tried invoking the End Point then its throwing this error. 

System.HttpResponse[Status=Service Unavailable, StatusCode=503]

public with sharing class LmsRestApiIntegration {

//LmsRestApiIntegration.invokeRestAPI()
@future(callout = true)
public static void invokeRestAPI(){
String URL = 'http://pasquote-bfapp.tent.trt.csaa.pri/QuickQuoteWebSvc/QQWebSvc.asmx';
String xmlContent = '';
xmlContent = '<?xml version="1.0" encoding="utf-8"?>';
xmlContent = xmlContent + '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
xmlContent = xmlContent + '<soap:Body>';
xmlContent = xmlContent + '<GetCityListFromZip xmlns="http://www.csaa.com/irv/quickquote/auto/2006/10/01">';
xmlContent = xmlContent + '<zipcode>92126</zipcode></GetCityListFromZip>';
xmlContent = xmlContent + '</GetCityListFromZip>';
xmlContent = xmlContent + ' </soap:Body>';
xmlContent = xmlContent + '</soap:Envelope>';
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setBody(xmlContent);
req.setHeader('content-type','text/xml');
req.setHeader('content-length', '0');
req.setEndpoint(URL);
req.setHeader('SoapAction', 'http://www.csaa.com//irv/quickquote/auto/2006/10/01/GetCityListFromZip');
req.setMethod('POST');
String response = '' ;
HttpResponse res = h.send(req);
response = res.getBody();

System.debug('Response :'+response);

}
}

Please guide.

Thank You
Shri
Just like we generate a PDF File using Apex/VF, Can we render Data in an XML format from a Page or anywhere else? And also, Can we Zip the attachment? The reason is, Thats how we are supposed to email the attachment to a particular address. Therefore,

1. Render data in an XML Attachment
2. Zip the attachment
3. Email the attachment. (I know we can do this)

Please guide

Thanks
Shri
Just like we generate a File using Apex, Can we render Data in an XML format? And also, Can we Zip the attachment? The reason is, Thats would we are supposed email the attachment to a Particular address. Therefore, 

1. Render data in an XML Attachment
2. Zip the attachment
3. Email the attachment. (I know we can do this) 

Thanks
Shri

Hello, 

Is there any ways where i can Partially inactivate an Inline Edit. Here is the scenario. 

Bascially i have a custom Related List which is a VF Page which supports an Inline Edit . I Also have a 'Mass Edit' button on the related list which opens up a 'Mass Edit' PageBlockSection. Whenever the Mass Edit button is clicked then i would like to inactivate the InlineEdit. Orelse keep it active. 

Thanks,
Shri


 

Hello, 

I have been trying to parse an WSDL into Salesforce and im receiving the following error. Please help.

Unable to find schema for element; {http://www.w3.org/2001/XMLSchema}schema

Hello, 



I was trying to Parse an XML into our Salesforce Dev org and I was getting this error. Kindly suggest what could be the problem. 

Unable to find schema for element; {http://www.w3.org/2001/XMLSchema}schema

Thanks,
Shri

Hello ,

We are planning to have a integration from Salesforce to an External System. Salesforce --> Lead Management System. Here I'm not sure if this will be only SOAP or REST could also be possible.

Before i start working on this, I would like to Integrate both Salesforce DEV and Salesforce UAT. I have Parsed the WSDL from UAT into DEV where 3 of Apex classes are created. From here onwards I'm not sure how can i take it forward. Like, Passing the Credentials and inserting/updating data from Dev to UAT.

Kindly suggest.
Shri

Hello, 


I have been getting this error. Since im using this free appliation for the first time online, It doest provide a free informatica support. Did anyof you face the same problem? What could be the problem? 
Since im testing the app, My task is light weight. Im planning to insert 2 Account records from one Sandbox instance to another. 

[FATAL] GetServerTimestamp failed. User [UserName]. Fault code [3]. Reason [SOAP Error : [Tag Error : MisMatch]. Please Contact Informatica Customer support.].
 

I always get confused with indexing. I would like to print these numbers in Ascending & Descending order. Can someone help. 

List<Integer> intergerList = new List<Integer> {33,2,45,343,433,22,111} ;

 

Can anyone share an example considering Account as an example. 

Thanks
Shri
Hello All,

I will try to frame my question in short.

End Goal : REST API Integration from Salesforce to a InHouse Lead Management System(LMS2)

SUCCESS Through Chrome APP
1.  All i need to do is retrieve values from LMS2. When i tried to use the Chrome APP 'Advanced Rest Client' and have passed the appropriate URL and Content in XML/TEST format in the form of POST methoed I was able to retrieve the values from LMS2 database.
For EG : If i pass 92126 then i was able to get 'SAN DIEGO' which is correct.

Here is the link (https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo?hl=en-US)for Advanced REST Client.


PROBLEM from Salesforce :

2) When i created this REST class in SAlesforce and tried invoking the End Point then its throwing this error.

System.HttpResponse[Status=Service Unavailable, StatusCode=503]

public with sharing class LmsRestApiIntegration {

//LmsRestApiIntegration.invokeRestAPI()
@future(callout = true)
public static void invokeRestAPI(){
String URL = 'http://pasquote-bfapp.tent.trt.ccc.pri/QuickQuoteWebSvc/QQWebSvc.asmx';
String xmlContent = '';
xmlContent = '<?xml version="1.0" encoding="utf-8"?>';
xmlContent = xmlContent + '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
xmlContent = xmlContent + '<soap:Body>';
xmlContent = xmlContent + '<GetCityListFromZip xmlns="http://www.ccc.com/irv/quickquote/auto/2006/10/01">';
xmlContent = xmlContent + '<zipcode>92126</zipcode></GetCityListFromZip>';
xmlContent = xmlContent + '</GetCityListFromZip>';
xmlContent = xmlContent + ' </soap:Body>';
xmlContent = xmlContent + '</soap:Envelope>';
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setBody(xmlContent);
req.setHeader('content-type','text/xml');
req.setHeader('content-length', '0');
req.setEndpoint(URL);
req.setHeader('SoapAction', 'http://www.ccc.com//irv/quickquote/auto/2006/10/01/GetCityListFromZip');
req.setMethod('POST');
String response = '' ;
HttpResponse res = h.send(req);
response = res.getBody();

System.debug('Response :'+response);

}
}

Please guide.

Thank You
Shri

Hello, 

I have implemented Custom Sorting on a VF page using Comparable Interface. If there are 10 records in a Page and few of the fields on the records are NULL then the List.Sort method is not functioning properly when there are NULL and NOT NULL fields included. Please suggest. 
 

Thanks

I am looking to change the color of the buttons in the hightlights panel to red or green depending on if they are completed. The buttons are screen flows and we have check boxes to indicate completion.
  • April 18, 2023
  • Like
  • 0
There are 6mem"s assigned under a North America role. When we are creating a user under the North America role there a assigning to Crop protection Queue membership, So the automatic assignment to Queue should be removed and user to be assigned to Queue manually... What should be the solution..
public class ScheduleMessageBatch implements Database.Batchable<SObject>{
    
    
    public Database.queryLocator start(Database.BatchableContext BC)
    {
        return Database.getQueryLocator('Select Id, DeliveryStatus__c, Source__c, ScheduledAt__c, MessageText__c, ToNumber__c, FromNumber__c From MessageHistory__c where DeliveryStatus__c = \'Scheduled\' AND Source__c = \'Drip Campaign\' AND ScheduledAt__c <= Datetime.now()');
        
    }
    public void execute(Database.BatchableContext BC, List<MessageHistory__c> messagehistoryList )  {
        
        
        for(MessageHistory__c mh : messagehistoryList) {
            MessageDesk mD = new MessageDesk();
            MessageInfo mi = new MessageInfo(mh);
            mD.sendSMS(mi);
        }
        
    }
    public void finish(Database.BatchableContext BC)
    {
        
    }
}
Hello Team,

I am getting the following error - 
This page has an error. You might just need to refresh it. Action failed: c:ContactListSearch$controller$searchKeyChange [Cannot read properties of undefined (reading 'setParams')] Failing descriptor: {c:ContactListSearch$controller$searchKeyChange} 
while running the app with the following code.

QuickContacts.app
<aura:application>
    <link href='/resource/bootstrap/' rel="stylesheet"/>
    <div class="navbar navbar-default navbar-static-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <a href="#" class="navbar-brand">Lightning Contacts</a>
            </div>
        </div>
    </div>
    <div class="container">
        <div class="row">
            <div class="col-sm-12">
                <c:ContactListSearch/>
                <c:ContactList/>
            </div>
        </div>
    </div>
</aura:application>

ContactList.cmp
<aura:component controller="ContactController">
    <aura:attribute name="contacts" type="Contact[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:handler event="c:SearchKeyEvent" action="{!c.searchKeyChange}"/>
    <ul class="list-group">
        <aura:iteration items="{!v.contacts}" var="contact">
            <li class="list-group-item">
                <a href="{! '#contact/' + contact.Id }">
                    <p>{!contact.Name}</p>
                    <p>{!contact.Phone}</p>
                </a>
            </li>
        </aura:iteration>
    </ul>
</aura:component>

ContactListController.js
({
    doInit : function(component, event)
    {
        var action=component.get("c.findAll");
        action.setCallback(this,function(a)
                           {
                               component.set("v.contacts",a.getReturnValue());    
                           });
    $A.enqueueAction(action);
    },
    searchKeyChange: function(component, event) {
        var searchKey = event.getParam("searchKey");
        var action = component.get("c.findByName");
        action.setParams({
          "searchKey": searchKey
        });
        action.setCallback(this, function(a) {
            component.set("v.contacts", a.getReturnValue());
        });
        $A.enqueueAction(action);
    }
})

ContactListSearch.cmp
<aura:component >
    <input type="text" class="form-control" placeholder="Search" onkeyup="{!c.searchKeyChange}"/>
</aura:component>

SearchKeyEvent.evt
<aura:event type="APPLICATION" access="global">
    <aura:attribute name="searchKey" type="String"/>
</aura:event>

ContactListSearchController.js
({
        searchKeyChange : function(component, event, helper) {
        
        var myEvent = $A.get("e.c:SearchKeyChange");
        myEvent.setParams({"searchKey":event.target.value});
        myEvent.fire();
   
    }
    })

Can anyone please help me to find the error?
Hi, 
  I am trying to write SOQL for below case but facing  issue "Semi join sub-selects are only allowed at the top level WHERE expressions and not in nested WHERE expressions".

Use case is to retreive the opportunity where Amount > 1000 (OR) OpportunityFieldHistory where FIELD='StageName' AND CreatedDate  LAST_N_DAYS:14.

My Query:

SELECT Id, Name from opportunity where  Amount > 1000 OR Id IN(SELECT OpportunityId from OpportunityFieldHistory WHERE Field='StageName' AND CreatedDate=LAST_N_DAYS:14))

Can you please help, how this can be acheived.
I wrote an apex class which works fine. However, the test class keeps failing with the error: System.EmailException: SendEmail failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Email body is required.: [] Not sure what I am doing wrong. Can you please help? I have attached my code and test class below

global class XYZLetter {   
    global static void sendLetter(List<String> recordId) {
        
//Get Files from ContentDocumentLink Object
    List<ContentDocumentLink> cdls = [select Id,ContentDocumentId,ContentDocument.Title,LinkedEntity.Name From ContentDocumentLink where LinkedEntityId=:recordId AND ContentDocument.Title LIKE 'xyz%'];
    
    Set<Id> contentDocumentIds = new Set<Id>();
    for (ContentDocumentLink cdl : cdls) {
        contentDocumentIds.add(cdl.ContentDocumentId);
    }   
        
    List<Id> attachmentIds = new List<Id>();    
//Get all related contentVersion file     
    List<ContentVersion> documents = ([SELECT Id FROM ContentVersion WHERE isLatest = true AND ContentDocumentId IN :contentDocumentIds]);
    for (ContentVersion doc : documents) {
        attachmentIds.add(doc.Id);
    }
    
//Get details on the Application    
   Card__c pcard = [SELECT Id,Letter_Failed__c, RecordTypeId FROM Card__c WHERE Id=:recordId];
   
    String cardholderContactId=pcard.Card_Applicant__c;

//-********************
 
    if(attachmentIds.size()==0){
        EmailTemplate NoXYZ = [SELECT id FROM EmailTemplate WHERE developerName = 'Letter_Not_Found'];
        
        OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'oxyxSF@COMPANY.COM'];
        String[] ccAddresses = new String[] {'cardinquiries@company.com'};
        
        //Apex Single email message
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        if ( owea.size() > 0 ) {
            mail.setOrgWideEmailAddressId(owea.get(0).Id);
        }    
      
        mail.setTemplateID(NoXYZ.id);//templateID
        mail.setTargetObjectId(cardholderContactId);// contact Id of cardholder
        mail.setCcAddresses(ccAddresses);
        //No attachment found here, so no need to try and attach mail.setEntityAttachments(attachmentIds);
        mail.setWhatId(pcard.Id);  
        Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {mail};
        Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
            if (results[0].success) {
                System.debug('The email for XYZ Letter not found was sent successfully.');
            } else {
                System.debug('The email for XYZ Letter not found failed to send: '+ results[0].errors[0].message);
                 pcard.XYZ_Letter_Failed__c = true;
             }
     
              Update pcard;
   }//end if attachmentIds.size()==0 (Send 'XYZ Letter Not Found' Template end)
//-********************

//-********************
   //Otherwise, end message as expected
    else {
        Id pcardRTypeId = [SELECT Id FROM RecordType WHERE sObjectType='Card__c' AND developerName ='PCard_Approval'].Id;
        Id finRTypeId = [SELECT Id FROM RecordType WHERE sObjectType='Card__c' AND developerName ='Information_Updates'].Id;

        EmailTemplate pcardET = [SELECT id FROM EmailTemplate WHERE developerName = 'X3_Approved'];
        EmailTemplate finET = [SELECT id FROM EmailTemplate WHERE developerName = 'X20_Information_Update_Approved'];
        EmailTemplate SingleFinET = [SELECT id FROM EmailTemplate WHERE developerName = 'X201_Single_Information_Update_Approved'];
        EmailTemplate MonthlyFinET = [SELECT id FROM EmailTemplate WHERE developerName = 'X202_Monthly_Information_Update_Approved'];
        
        String et;
        if (pcard.RecordTypeId == pcardRTypeId){
            et = pcardET.Id;
        }
        else if (pcard.RecordTypeId == finRTypeId){
            //et = finET.Id;
            if (pcard.Monthly_Purchase_Card_Update__c && pcard.Single_Purchase_Card_Update__c){
                et = finET.Id;
            }
            else if(pcard.Monthly_Purchase_Card_Update__c){
                et = MonthlyfinET.Id;
            }
            else if(pcard.Single_Purchase_Card_Update__c){
                et = SingleFinET.Id;
            }
        }

       
        

        OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'XYZsalesforce@COMPANY.COM'];
  
        String[] ccAddresses = new String[] {'p-cardinquiries@COMPANY.COM'};
      
        if (pcard.PCard_Supervisor__c != null){
           ccAddresses.add(pcard.PCard_Supervisor__c);
        }
        if (pcard.Approving_Official_Lookup__c != null){
           ccAddresses.add(pcard.Approving_Official_Lookup__c);
        }
        
        List<String> idList = new List<String>();
        Group g = [SELECT (select userOrGroupId from groupMembers) FROM group WHERE NAME =:pcard.CPublic_Group__c];
        for (GroupMember gm : g.groupMembers) {
            idList.add(gm.userOrGroupId);
        }
        
        User[] usr = [SELECT email FROM user WHERE id IN :idList];
        for(User u : usr) {
            ccAddresses.add(u.Id);
        }
  
    //Apex Single email message
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        if ( owea.size() > 0 ) {
            mail.setOrgWideEmailAddressId(owea.get(0).Id);
        }    

    mail.setTemplateID(et);//templateID
    mail.setTargetObjectId(cardholderContactId);// contact Id of cardholder
    mail.setCcAddresses(ccAddresses);
    mail.setEntityAttachments(attachmentIds);
    mail.setWhatId(pcard.Id);  // card recordId
        
    Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {mail};
    Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
        if (results[0].success) {
           System.debug('The email was sent successfully.');
        } else {
           System.debug('The email failed to send: '+ results[0].errors[0].message);
        }

        
    }

Here is the test class:
@isTest
public class DPALetterTest {
    static testMethod void sendEmailwithAttachment() {
        Test.startTest();
        
        EmailTemplate et = [SELECT id FROM EmailTemplate WHERE developerName = 'X3_PCard_Approved'];
        Id pcardRTypeId = [SELECT Id FROM RecordType WHERE sObjectType='PCard__c' AND developerName ='PCard_Approval'].Id;
        Id finRTypeId = [SELECT Id FROM RecordType WHERE sObjectType='Purchase_Card__c' AND developerName ='Information_Updates'].Id;
       // String pcardRTypeId = recTypeId.Id;
        
        Account acc = new Account();
        acc.Name='ABCTest';
        insert acc;

        String profileName1 = 'Card Application User';
        
        User admin = [SELECT Id, Username, UserRoleId FROM User WHERE Profile.Name = 'System Administrator' AND UserRole.Name='XYZSystem Admin' LIMIT 1];
       
        System.runAs(admin){

            User u1 = new User(
                ProfileId = ([SELECT Id FROM Profile WHERE Name=:profileName1].Id),
                LastName = 'user1',
                Email = 'test.user1@test.com',
                Username = 'test.ccpuser1@test.com',
                CompanyName = 'XYZ',            
                Alias = 'alias',          
                TimeZoneSidKey = 'America/Los_Angeles',
                EmailEncodingKey = 'UTF-8',
                LanguageLocaleKey = 'en_US',
                LocaleSidKey = 'en_US'             
            );
            insert u1;

            User u2 = new User(
                ProfileId = ([SELECT Id FROM Profile WHERE Name=:profileName1].Id),
                LastName = 'user2',
                Email = 'test.user2@test.com',
                Username = 'test.ccpuser2@test.com',
                CompanyName = 'CBER',            
                Alias = 'alias',          
                TimeZoneSidKey = 'America/Los_Angeles',
                EmailEncodingKey = 'UTF-8',
                LanguageLocaleKey = 'en_US',
                LocaleSidKey = 'en_US'             
            );
            insert u2;

         Group gp = [SELECT ID FROM Group WHERE Name='PCard XYZ CCP Group'];   
        GroupMember gpm = new GroupMember();
        gpm.GroupId = gp.Id;
        gpm.UserOrGroupId = u1.Id;            
        Database.insert(gpm);

        Contact applicant1 = new Contact(firstName='test', lastName = 'applicant11',accountId=acc.id, email ='test.applicant11@abctest.com');
        insert applicant1;
        Contact supervisor1 = new Contact(firstName='test', lastName = 'supervisor12',accountId=acc.id, email ='test.supervisor12@abctest.com');
        insert supervisor1;  
        Contact ao1 = new Contact(firstName='test', lastName = 'ao11',accountId=acc.id, email ='test.ao11@abctest.com');
        insert ao1;              
        
        Card__c app1 = new Card__c(); 
        
        app1.RecordTypeId = pcardRTypeId;
        app1.Cardholder_Name__c  = 'Test Applicant11';
        app1.Cardholder_Email_Address__c='Test.Applicant11@abctest.com';
        app1.PCard_Applicant__c = applicant1.Id;
        app1.PCard_Supervisor__c = supervisor1.Id;
        app1.Approving_Official_Lookup__c = ao1.Id;      
        insert app1; 
            
        Purchase_Card__c app2 = new Purchase_Card__c(); 
        
        app2.RecordTypeId = finRTypeId;
        app2.Cardholder_Name__c  = 'Test Applicant11';
        app2.Cardholder_Email_Address__c='Test.Applicant11@abctest.com';
        app2.Card_Applicant__c = applicant1.Id;
        app2.Card_Supervisor__c = supervisor1.Id;
        app2.Approving_Official_Lookup__c = ao1.Id;
        insert app2; 
   
          
            // Insert Salesforce Files using Apex Class:
         //Create Document
        ContentVersion cv = new ContentVersion();
        cv.Title = 'XYZ Test Document';
        cv.PathOnClient = 'TestDocument.pdf';
        cv.VersionData = Blob.valueOf('Test Content');
        cv.IsMajorVersion = true;
        Insert cv;
                            
             //Get Content Documents
    Id conDocId = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:cv.Id].ContentDocumentId;
 
    //Create ContentDocumentLink 
    ContentDocumentLink cdl = New ContentDocumentLink();
    cdl.LinkedEntityId = app1.Id;
    cdl.ContentDocumentId = conDocId;
    cdl.shareType = 'V';
    cdl.Visibility = 'AllUsers';
    Insert cdl; 
            
    ContentDocumentLink cdl2 = New ContentDocumentLink();
    cdl2.LinkedEntityId = app2.Id;
    cdl2.ContentDocumentId = conDocId;
    cdl2.shareType = 'V';
    cdl2.Visibility = 'AllUsers';
    Insert cdl2; 
                       
        
         Integer emailbefore = Limits.getEmailInvocations();

         List<String> recordIds=new List<String>{app1.Id};  
         List<String> finRecordIds=new List<String>{app2.Id};  
         XYZLetter.sendLettXYZer(recordIds);   
         XYZLetter.sendXYZLetter(finRecordIds);    
  
        system.assertNotEquals(emailbefore,Limits.getEmailInvocations(),'should have decreased');
        Test.stopTest();         
        
    }
}

}
TLDR; Instead of native form submission for web2lead form, I am using REST API to hit the https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8 endpoint with form data in the request body to submit the Web2Lead form. And it's getting CORS error.
---
While the raw form looks like this
 
<form action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">


I have built the form using some custom components in React and providing the below `handleSubmit` handler to it to submit the form.
const actionUrl =
    'https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';

  const handleSubmit = async (formValues) => {
    try {
      await axios.post(actionUrl, formValues, {
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
        },
      });
    } catch (error) {
      console.error(error);
    }
  };

And this axios request is getting CORS error on the browser although I added the domain to the whitelist on the security settings.
Are Web2Lead forms intended to be submitted as a native form always? Is there a way to submit this form using axios without getting the CORS error?
Keep getting "Choose a different report type. This one has no common fields with the other report types in this joined report." when trying to join with a custom object.
Does anyone know what this error means when trying to Name and Describe your recommendation in Einstein Recommendation Builder?User-added image
Is there any way to bypass lookup filter validation for specific user ?
Hello, 
I am trying to write several formulas to use in a flow to check if a date is in between a range. The issue is I want it to be sustainable and only compare the Month and Day only, not the year. 

Example:
say the input date field is March 1, 2023

I want to know if it's equal to or greater than January 11 and less than or equal to April 10th and not include the year. 

Is this possible?

Tried something like this and it failed: 

AND(
MONTH({!$Record.Comp_Approved_Date__c}) >= 1,
MONTH({!$Record.Comp_Approved_Date__c}) <= 4,
DAY({!$Record.Comp_Approved_Date__c})  >= 11,
DAY({!$Record.Comp_Approved_Date__c})  <= 10
)
I need to access the SHOPPER API which needs the access_token, but I didn't find the document which suggests how I can do that or any other alternate way to do it.
Thanks 

I am unable to update [patch] standardvalueset through tooling api and here's request body but receiving bad id 4 and malformed id

 

Request Body:

{
 
"Metadata" : {
      "sorted" : false,
      "standardValue" : [ {
        "allowEmail" : null,
        "closed" : null,
        "color" : null,
        "converted" : null,
        "cssExposed" : null,
        "default" : false,
        "description" : null,
        "forecastCategory" : null,
        "groupingString" : null,
        "highPriority" : null,
        "isActive" : null,
        "label" : "Agriculture",
        "probability" : null,
        "reverseRole" : null,
        "reviewed" : null,
        "urls" : null,
        "valueName" : "Agriculture",
        "won" : null
      }, {
        "allowEmail" : null,
        "closed" : null,
        "color" : null,
        "converted" : null,
        "cssExposed" : null,
        "default" : false,
        "description" : null,
        "forecastCategory" : null,
        "groupingString" : null,
        "highPriority" : null,
        "isActive" : null,
        "label" : "Chemicals1",
        "probability" : null,
        "reverseRole" : null,
        "reviewed" : null,
        "urls" : null,
        "valueName" : "Chemicals1",
        "won" : null
      } ],
      "urls" : null
    },
     "FullName" : "Test",
    "MasterLabel" : "Test"
  } 
 

I have below code. I need to generate a csv file to show to results of 'userdetaillist'.

public class UserService {
    private static String profileName = 'Chatter Free User';
    private static String ps7Name = 'Test Chatter Free7';
   Public static List<UserDetail> userDetailList = new List<UserDetail>();
    
    
    private static List<String> ps1_ps10NameList = new List<String>{
        'Test Chatter Free1','Test Chatter Free2','Test Chatter Free3','Test Chatter Free4','Test Chatter Free5','Test Chatter Free6','Test Chatter Free7','Test Chatter Free8','Test Chatter Free9','Test Chatter Free10'};
    
    
    public static List<UserDetail> getUserPermissionDetails(){
        
      Map<Id, User> userMap = new Map<Id, User>([SELECT Id
                                  FROM User
                                  WHERE Profile.Name = :profileName and Id IN (SELECT AssigneeId 
                                                   FROM PermissionSetAssignment
                                                   WHERE PermissionSet.label = :ps7Name and PermissionSet.IsOwnedByProfile =false)]);
        //System.debug(usermap);
     Map<Id, List<String>> permissionSetMap = new Map<Id, List<String>>();
        
        for(PermissionSetAssignment psa : [SELECT AssigneeId, PermissionSet.label
                                              FROM PermissionSetAssignment
                                              WHERE AssigneeId = : userMap.keySet()
                                                  AND (PermissionSet.label IN :ps1_ps10NameList
                                                     OR PermissionSet.label NOT IN :ps1_ps10NameList)and PermissionSet.IsOwnedByProfile =false
                                              ORDER BY AssigneeId, PermissionSet.label])
        {
            List<String> tempList = new List<String>();
               if(permissionSetMap.containsKey(psa.AssigneeId))
                tempList = permissionSetMap.get(psa.AssigneeId);
            
            tempList.add(psa.PermissionSet.label);
            
            permissionSetMap.put(psa.AssigneeId, tempList);
                    
        }

        return evaluateUser(permissionSetMap);
        
    }
    
    
    private static List<UserDetail> evaluateUser(Map<Id, List<String>> permissionSetMap){

        Boolean additional;

        List<UserDetail> userDetailList = new List<UserDetail>();

        List<String> foundList = new List<String>();        
        for(Id id : permissionSetMap.keySet())
        {
            UserDetail ud = new UserDetail();
            additional = false;
            /*system.debug(permissionSetMap.get(id));*/
            foundList.clear();

            for(String str : permissionSetMap.get(id)){
            
                if(!ps1_ps10NameList.contains(str)){
                    additional = true;
                }else{
                    foundList.add(str);
                }
                /*system.debug(userDetailList);*/
            }            
            
            ud.Id = id;
            ud.permissionSetList = permissionSetMap.get(id);
            
            if(additional && ps1_ps10NameList.size() == foundList.size())
                ud.status = 'No Change And Additional';
            else if(additional && ps1_ps10NameList.size() != permissionSetMap.get(id).size())
                ud.status = 'Missing And Additional';
            else if(!additional && ps1_ps10NameList.size() != foundList.size())
                ud.status = 'Missing';
            else if(!additional && ps1_ps10NameList.size() == foundList.size())          
                ud.status = 'No Change';
                
            userDetailList.add(ud);
        }
        System.debug(JSON.serializePretty(userDetailList));
            return userDetailList;
       
       
    }
    
    public class UserDetail {
        
        public Id id;
        public List<String> permissionSetList;
        public String status;
    } 
   
}
 
public class ApexCollection {
    
public static void apexMethod(string a)
{
    
    String[] arr=new String[]{'A','B','C','D','A'};
        integer s1=integer.valueOf(arr);  
       System.debug( 'intVal value is ' + s1 );

error: Method does not exist or incorrect signature: void apexMethod() from the type ApexCollection.

I am getting error on this code, please response.
when a customer sends emails to 2 different groups, then when an agent tries to reply then defaults to picking 1st mail id from the "To address" as default "From Address", Now agent requests irrespective  "To address" they want their group's mailbox.

 
Reading through the documentation (https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_organization.htm), the Organization object should have a field DefaultTerritoryAccountAccess. However when I query /services/data/v46.0/sobjects/Organization/describe, DefaultTerritoryAccountAccess isn't in the returned fields, and when I include it in a soql query, I get the below error:

"errorCode":"INVALID_FIELD","error_description":"","message":"\nDefaultLeadAccess, DefaultOpportunityAccess, DefaultTerritoryAccountAccess FROM\n ^\nERROR at Row:1:Column:125\nNo such column 'DefaultTerritoryAccountAccess' on entity 'Organization'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
Hi there,
Hope all is fine for you. I'm working on Integrations between ERP and Salesforce and willing to use Composite Resources to transfer Orders from our ERP to Salesforce.
Issue is that, even if it works most of the time, I'm having issues when Order contains more than X number of lines as Composite API allows up to 25 Subrequests only. I then discovered the Composite Graph API which raised this limit to 500, which was then pretty much OK, until I figured out that my subrequests were not executed in Order. Looking into documentation, I found the CollateSubrequests parameter, but this one seems to be only available in Composite API (back to the limit of 25 subrequests).
Does anybody know if there is a way to guarantee the order of execution for my subrequests in a Composite Graph API (for some Business reasons, I have to respect this order of execution which requires me to update the Order first (to Unlock it), then Delete Some Order Lines (which has to happen before I change the Currency on the Order), then Update the Order again (for currency), then re-Insert my Order Lines, then finally update my Order (to Lock it back).

Thanks in advance for your advices here

Cédric
I have below requirment - 
Train and Coach are 2 objects. Where I need to build logic based on train schedule and availibility. From UI side admin can add the coach to the train. 

Train (Parent Object - From, To, Timings)
Coach (Child Object - From, To, Timings) Field is there. 

Now from UI side when user book the tickets. based on given 3 fields I need to add coachs in the train. lets say next week on monday there will 3 trains are schedule from X to Y location. now today we see many passanger book the train from X to Y location. so basically, based on timings I need to add number of coaches in next week train so I can accomodate all customers. Its not like 1 train run with 5-6 coach, while other train runs with 30-35 coach. there has to balance. 

Please let me know if need further clarification in scenario. 
I found this out the very hard way and I would like to share my findings to either warn others, or find out if I've done something wrong somehow.  Sobjects cannot be handed lists of objects via addAll (even though they can be added objects one at a time through add, and OTHER methods that have sObject lists as parameters can accept object lists).

I'll show by example:
Account a = new Account();
sObject s
LIST<sObject> sOjbList = new LIST<sObject>();
sOjbList.add(s);
sOjbList.add(a);
That works perfectly fine, as you'd expect.
sObject s1;
sObject s2;
LIST<sObject> sList = new LIST<sObject>{s1, s2};
LIST<sObject> sOjbList = new LIST<sObject>();
sOjbList.addAll(sList);
Also works fine.

This, however, will fail.
LIST<Account> aList = new LIST<Account>{new Account(), new Account()};
LIST<sObject> sOjbList = new LIST<sObject>();
sOjbList.addAll(aList);
It gives the errors:
Incompatible argument type LIST for All method on LIST
OR
Incompatible argument type LIST<Account> for All method on LIST<SObject>
(Based on if you're using the Developer Console or something else, like MavensMate)

But don't fret, there's a solution (albeit a silly one)
private LIST<sObject> objToSobj(sObject[] objList)
{
	return objList;
}
That's right, pass your objList through this (and it will let you without problem) and all works fine.

Thoughts?
I'm experiencing a strange error with Salesforce's Inline Editing in a custom visualforce page. I have a sObject with a date field called Start_Date__c, and I have inline editing set up in the VisualForce like this:
<apex:page standardController="Product_Assignment__c"
    tabStyle="Product_Assignment__c"
    extensions="TestInlineEditControllerExt">

<apex:form id="productForm">
    <apex:pageBlock >
        <apex:pageMessages />
        <apex:pageBlockTable value="{!productAssignments}" var="productAssignment">
            <apex:column headerClass="h1">
                <apex:facet name="header">Start Date</apex:facet>
                <apex:outputField value="{!productAssignment.Start_Date__c}">
                    <apex:inlineEditSupport changedStyleClass="dirtyField" event="ondblclick" showOnEdit="saveChanges" />
                </apex:outputField>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
    <apex:commandButton id="saveChanges" reRender="productForm" action="{!quicksave}" value="Save Changes" styleClass="saveChangesButton" />
</apex:form>
</apex:page>
The custom controller is (this is not my exact code, but it's enough to replicate the issue):
public with sharing class TestInlineEditControllerExt {
    public List<Product_Assignment__c> productAssignments { get; set; }

    public TestInlineEditControllerExt(ApexPages.StandardController stdController) {
        stdController.addFields(new List<String> { 'Start_Date__c' });
        productAssignments = new List<Product_Assignment__c> {
            (Product_Assignment__c)stdController.getRecord()
        };
    }
}
This works well in normal use cases. If I edit the field an input a deliberately incorrect value (like 'abcdef'), and press save, I receive the expected error: Start Date: Invalid Date and Time.

After this, if I attempt to click the revert button and save again, I receive a cryptic error message: Start Date: Value cannot exceed 0 characters.

I've tried following this pattern on a standard detail page, but this issue only seems to happen on my custom visualforce page. I've also tried using a custom action (instead of "quicksave") on my controller, but have the same issue (error message, controller is never called). We do not have any validation rules in place for this field.

Does anybody know why this error is happening and how I can fix this issue? It seems to only happen when I have an inline editing component inside of an apex:pageBlockTable or apex:repeat element.

Today we’re excited to announce the new Salesforce Developers Discussion Forums. We’ve listened to your feedback on how we can improve the forums.  With Chatter Answers, built on the Salesforce1 Platform, we were able to implement an entirely new experience, integrated with the rest of the Salesforce Developers site.  By the way, it’s also mobile-friendly.

We’ve migrated all the existing data, including user accounts. You can use the same Salesforce account you’ve always used to login right away.  You’ll also have a great new user profile page that will highlight your community activity.  Kudos have been replaced by “liking” a post instead and you’ll now be able to filter solved vs unsolved posts.

This is, of course, only the beginning  and because it’s built on the Salesforce1 Platform, we’re going to be able to bring you more features faster than ever before.  Be sure to share any feedback, ideas, or questions you have on this forum post.

Hats off to our development team who has been working tirelessly over the past few months to bring this new experience to our community. And thanks to each of you for helping to build one of the most vibrant and collaborative developer communities ever.
 

As many of you have discovered, our developer community is awesome. The wealth of knowledge here is phenomenal. This is an all volunteer community and people who take the time to help and post answers do so totally on their own initiative. With that said when someone provides the right answer to your question please take the time to mark their answer as the accepted solution. Also give them a kudos if they've really gone the extra mile to help out. Show some love ;)

I recently downloaded APEX Data Loader version 27.0.1. My colleague has a batch job that does a bulk upload of records to our salesforce account. I tried running the script on my computer and kept getting an error. I narrowed down the culprit to be the output of the command line when running encrypt.bat. 

 

When running the command line prompt "ecrypt.bat -g seed_text_here", the script is expecting the output to be just the key that should be saved to key.txt. This is consistent with the online video tutorial located here: http://www.salesforce.com/_app/video/data_loader/help/data_loader_cli.jsp

 

However, when I run "ecrypt.bat -g seed_text_here" on my computer, I get the following output: 

2013-04-24 15:06:21,050 INFO [main] security.EncryptionUtil main (EncryptionUtil.java:304) - encrypted_password_key_here

 

It appears to be an issue with setting the logging level. Any ideas on how to change this? 

 

Thanks.

  • April 24, 2013
  • Like
  • 1