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

  • Chatter
    Feed
  • 17
    Best Answers
  • 3
    Likes Received
  • 5
    Likes Given
  • 32
    Questions
  • 305
    Replies
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

 
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?
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']; 
    }   
}
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. 
In flow, I would like to get a records from an object and check from an array(or an alternative) if such match exist then for those that does not exist, I need to create that records with predetermined values. So here is my sequence:
1. Fetch records for object A with filter user and year
2. from the result with perhaps an array? (January~December - as text) determine which value have no match.
3. From the list of non existing record, iterate on array with missing Month and create those records with default values.
 
I dont know how to implement or create the flow for Item 2 & 3.
Any experts help is greatly appreciated. Thank you in advance.
I'm creating a registration handler to provision new users to my Community site.  
When a user is logging in from a 3rd party SSO, I will have their email.   I want to use their email to see if they are already in salesforce as a contact.  I'm struggling with the code.  
 
When a user logs in for first time, I'll create a new Community User.
If the user already exists as a Contact, then I just link that contact to the Community User.
If the user does not already exist as a Contact then I create a new contact and link to the Community User.  
 
Account SFCOMMUNITYACCOUNT = [SELECT Id FROM account WHERE name = 'New Community User'];
ID SFCOMMUNITYACCOUNT_ID = SFCOMMUNITYACCOUNT.id;
        
// Get user details from KeyCloak
Contact SFCONTACT = new Contact();
SFCONTACT.email = KeyCloakData.email;
SFCONTACT.lastName = KeyCloakData.lastName;
SFCONTACT.firstName = KeyCloakData.firstName;
 
// if user does not exist as a Contact, create a new Contact & assign to account New Community User
SFCONTACT.accountId = SFCOMMUNITYACCOUNT_ID;
// if user does exist as a Contact, use their existing Contact info
SFACCOUNT.accountId = [SELECT Id from Account WHERE email =:KeyCloakData.email];
     
upsert SFCONTACT Contact.fields.Email; // If the contact exists, then update.  If the contact did not exist, then create it.
 
But I don't know how to write the code to lookup Contacts to see if any already are using this email.   Im pretty sure I use SELECT but and stuck.  Anyone have any suggestions.?
// if user does not exist as a Contact, create a new Contact & assign to account New Community User
SFCONTACT.accountId = SFCOMMUNITYACCOUNT_ID;
// if user does exist as a Contact, use their existing Contact info
SFACCOUNT.accountId = [SELECT Id from Account WHERE email =:KeyCloakData.email];
Hi All,

Here is my business requirement and I never worked on webservices. 

1. We have specif objects and fields to consume by Oracle.
2. Oracle will consume the webservice and then should be able to  updated few fields in SFDC.

My Assumptions:
Simply generate WSDL and provide them to consume the webservice?
or Do we have to write any classes for each object to expose the data?

Please help me, how I have to achieve this.

regards,
Ajay

  • August 05, 2014
  • Like
  • 0
Hi

Is it possible to filter child records to only the one which is added recently (based on created date).. i have a requirement to get the rullup summary for only the recently added child object field value.

i know we can do via apex. just wanted to check if there is any option with config

thanks
Hello guys,i would like to know.How many connect Apps i can have in one Salesforce organization?
Hi,
I was wondering which method is closer to best practice:


List<CampaignMember> members = [Select Id, Status From CampaignMember Where Status='Registered'];
Set<CampaignMember> memSets = new Set<CampaignMember> (members);

OR 

List<CampaignMember> members = [Select Id, Status From CampaignMember Where Status='Registered'];
Set<CampaignMember> memSets = new Set<CampaignMember> ();

memSets.addAll(members)

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

Hi, 

 

Can someone refer me any links which would describe about the Integration from Salesoforce --> External System using OAuth Mechanism. Please make sure the first call goes from Salesforce. Not the other way around. 

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.].
 

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

Hi,
create one button on account, upload one csv file to account and whenever I click on button It should create Accounts from the data present in csv file using lightning component. can anyone help how can I do that?


Thanks,
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

 
Hi guys,

I have a Custom Object called Weekly Plan which has a Date field called "Start of Week", a User Field (lookup) as well as other fields. The Date Field "Start of Week" always starts with Sunday. Example: 5th Feb 2023, 12th Feb 2023, and so on.

On the Contact Page, I have a checkbox called "Transfer Ownership". There is an associated Work Flow Rule that will transfer ownership of the Contact Record to someone else ONLY if there is an entry under Weekly Plan under this user for the previous Sunday. For example. if a user wishes to own a record today (say 07 Feb 2023), then the workflow rule should ONLY transfer ownership if a record under this user exists for a Weekly Planner for 29th Jan 2023 (previous week's Sunday).

Any idea how to accomplish this? Basically, I need to check the existence of a record under a Custom Object for the previous week's Sunday. If it exists, it can go ahead. I am not sure how to get to the "previous week Sunday" automatically or to check the existence of a record under a Custom Object in a Workflow Rule.

Thank you!
Hi Community,

I have inherited an aura component that basically prints a list of records dispalyed right down below for the community users to print.
This was written back in 2017 and no body has seen it working.
I played around a bit and observed that The URL for salesforce community being used under Lightning experience Transition Assistant--> Feature Settings--> All Sites is changed to following
New URL
https://community.ausure.com.au
The URL being used in Controller.Js is 
"url": "http://ausureib.force.com/AusureCommunity/MyCPDPointsRegister?recordId="+recordId

I am not sure how to construct a correct URL so that it prints all the records of CPD Register Points for a community user properly on clicking the button. 

My Controller Code.
({
    openCPDPointsList : function(component, event) {
    var urlEvent = $A.get("e.force:navigateToURL");
    var recordId = component.get("v.recordId");    
        urlEvent.setParams({
            url:"http://ausureib.force.com/AusureCommunity/MyCPDPointsRegister?recordId="+recordId           
        });
    urlEvent.fire();
    },
})

Tried constructing URL Like
 url": "https://community.ausure.com.au/s/my-cpd-register?recordId="+recordId
But this brings me back to the same page instead of taking me to printable view.

User-added image
I need to compare one list to another but it is not allowing me to do so
public class ContactTriggerHandler {
    public static void IsPricingLetter(List<Contact> con){
            Id CRMUSRecordType = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('CRM Contact US').getRecordTypeId();
           //Get a list of all contact ID's that have an active Relationship and of the Pricing Letters type 
        list<accountcontactrelation> PricingLettersCheck = new list<accountcontactrelation>([SELECT id,ContactID,roles From accountContactRelation 
                                                                                           WHERE contactid in :con AND Roles INCLUDES (:label.messer_us_pricing_letter) AND isactive=true]);
        
        
        List<Contact> ContactLookup = new List<Contact>();
        for(Contact ConList :con){
            if (ConList.recordtypeid==CRMUSRecordType){
    //I NEED TO COMPARE THE PRICINGLETTERS CHECK HERE>>       if(conlist.id IN :PricingLettersCheck.contactid){
                
                ContactLookup.add(ConList);
                }
                    }//end if
        }//end for loop

 
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. 
trigger AuthorResearchPaperTrigger on Author_Research_Paper__c (before insert) {
    switch on trigger.operationType{
        when BEFORE_INSERT{
            Set<id> researchPaperIdSet = new Set<id>();
            Set<id> authorIdSet = new Set<id>();
            for(Author_Research_Paper__c authRePaperObj : trigger.new){
                if(authRePaperObj.Research_Paper__c != null){
                    researchPaperIdSet.add(authRePaperObj.Research_Paper__c);
                }
                if(authRePaperObj.Author__c != null){
                    authorIdSet.add(authRePaperObj.Author__c);
                }
            }
            List<Author_Research_Paper__c> authorResearcPaperList = [SELECT id FROM Author_Research_Paper__c WHERE Research_Paper__c IN : researchPaperIdSet AND Author__c IN : authorIdSet];
            List<String> researchPaperNameList = new List<String>();
            List<String> authorNameList = new List<String>();
            for(Author_Research_Paper__c authRePaperObj : authorResearcPaperList){
                researchPaperNameList.add(authRePaperObj.Research_Paper__c);
                authorNameList.add(authRePaperObj.Author__c);
            }
            for(Author_Research_Paper__c authRePaperObj : trigger.new){
                if(researchPaperNameList.contains(authRePaperObj.Research_Paper__c) && authorNameList.size() > 5){
                    authRePaperObj.addError('Only 5 Authors are allowed.');
                }
            }
        }
    }
}
I have one LWC can be used to upload a Image and display the image
 
HTML:
<template>
    <input type="file"  name="image" id="file"  onchange={loadFile} style="display: none;">
    <label for="file" style="cursor: pointer;">Upload</label>
    <img id="output" width="200" />
</template>
 
JS:
loadFile(event) {
    var image = this.template.querySelector('img');
    image.src = URL.createObjectURL(event.target.files[0]);
    console.log(image.src);
    console.log(image);
    }
 
This is giving temporary url of the image uploaded.
This url I am getting in the console is not working when I put that in Image Src tag in a separate LWC component.

How to get the original image url uploaded.
So that I can store this url in Custom field and show the image based on that url in that field. when any new image uploaded I will change url in the custom field and show new image based on that irl in that Custom Field(URL).

Hi Everyone,

Does more number of method invocation within a class or method reduce performance in apex ?

Hello Everyone, 
I need one help in writing validation rule. Requirement is -
We have six look ups of User on a custom object.When user tries to create a record each look up should have unique value , no values should be repeated . User should see an error message when he tries to create a record with duplicate lookup value. Can anyone please me on the same. 
Thanks in advance

Hello Everyone,
I am creating a form with the help of record edit form in LWC to create a record. Form has six lookup fields of User.Now the requiremen is, all the six look ups should have unique value , no values should be repeated . User should see an error message when he tries to create a record with duplicate lookup value. Can anyone please me on the same. Can i use validation rule or trigger here.
Thanks in advance
AND(
$UserRole.Name <> 'System Administrator',
$Setup.Migration_Admin__c.AdminId__c <> $User.Id,
CASE( RecordType.Name ,
'Rental', 1,
'Retail', 1,
'Corporate/System Help', 1,
'Customer Experience-Quiq', 1,
'Custom'
0 ) = 1,
OR(
AND(
TEXT(Status) = 'Solved',
OR(
ISBLANK(TEXT(tb_Type__c)),
ISBLANK(TEXT(tb_Category__c))
)
)
I keep getting an error, whcih is attached in this post. User-added image
Need assistance, please
 
Hi, I have developed a custom notification in Apex using a page reference to an Aura component, and it works fine (user clicks on notifications under the Bell icon top right and get forwarded to the aura component). But I cannot find a way how to cleanup old notifications, is there a way, please? The system doesn't cleanup automatically, it probably must be done programmatically.
My apex code: 
Messaging.CustomNotification notification = new Messaging.CustomNotification();
notification.setTitle('...');
notification.setBody('...');
notification.setSenderId(UserInfo.getUserId());
notification.setNotificationTypeId([SELECT Id FROM CustomNotificationType WHERE DeveloperName ... LIMIT 1].Id);
User user = [SELECT Id FROM User WHERE ... LIMIT 1];
Map<String, Object> pageRef = new Map<String, Object>{
        'type' => 'standard__component',
        'attributes' => new Map<String, Object>{
                'componentName' => 'c__...'
        },
        'state' => new Map<String, Object>{
                'c__jobId' => ...,
                'c__userId' => ...
        }
notification.setTargetPageRef(JSON.serialize(pageRef));
notification.send(new Set<String>{
        user.Id
});

then the Aura component: 
implemets="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,lightning:isUrlAddressable">
vf page
<apex:page controller="AccountsSearchController" >
    <div style="margin: 1%;">
        
    <apex:form >
        <apex:pageBlock >
            <span>Account Name:</span>
                        <apex:selectList value="{!selectedAccountId}" size="1">
                <apex:selectOptions value="{!accountOptions}" />
            </apex:selectList>
             <apex:commandButton action="{!getDetails}" value="Get Contacts"/>

           <apex:pageBlockSection id="display" title="Related Contacts">              
        <apex:pageBlockTable value="{!relatedContacts}" var="contact" style="border:1px solid black;">
        <apex:column >
        <apex:facet name="header">
        <input type="checkbox" id="checkAllBox" onclick="selectAllCheckboxes(this,'inputId')"/>
            <script>
                function selectAllCheckboxes(obj,receivedInputID){
                var inputCheckBox = document.getElementsByTagName("input");
                for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                inputCheckBox[i].checked = obj.checked;
            global var i = obj.checked;
                        }
                        }
                }
            
            </script>
                </apex:facet>
            
        <apex:inputCheckbox id="checkboxShowP" value="{!isChecked}">
            <apex:actionSupport event="onchange" action="{!click}"/>
        </apex:inputCheckbox>
            
        </apex:column>
        <apex:column headerValue="Contact Name" style="width:200px;border:1px solid black;">
                <apex:outputField value="{!contact.Name}" />
        </apex:column>
        <apex:column headerValue="Contact Email" style="width:200px;border:1px solid black;">
             <apex:outputField value="{!contact.Email}" />
        </apex:column>
        <apex:column headerValue="Owner ID" style="width:200px;border:1px solid black;">
             <apex:outputField value="{!contact.OwnerId}" />
        </apex:column>
        </apex:pageBlockTable>
             <apex:commandButton value="Update Selected"/>
        </apex:pageBlockSection>
        </apex:pageBlock>
        </apex:form>
        </div>
</apex:page>
controller:
public with sharing class AccountsSearchController {
  public List<Account> selectedAccount {get; set;}
  public Boolean isChecked{ get; set; }
  public List<Contact> relatedContacts {get; set;}
  public List<Contact> SelectedContacts {get; set;}
  public List<Contact> checkedCon {get; set;}
  public List<Contact> i {get; set;}
  public List<SelectOption> accountOptions {get; set;}
  public String selectedAccountId {get; set;}
  public String selected {get; set;}
  List<Contact> contacts = new List<Contact>();

    
  public AccountsSearchController() {
    accountOptions = new List<SelectOption>();
    for (Account acc : [SELECT Id, Name FROM Account]) {
      accountOptions.add(new SelectOption(acc.Id, acc.Name));
    }
  }

  public void getDetails() {
    selectedAccount = [SELECT Id, Name, Phone, (SELECT Id, Name, Email, AccountId, OwnerId FROM Contacts) FROM Account WHERE Id = :selectedAccountId LIMIT 1];
    relatedContacts = selectedAccount[0].Contacts;
  }
     

  
     public void click(){
        for (Contact con : Contacts) {
                    if(isChecked==true){
        con.LastName = 'Updated ' + contact.LastName;
            contacts.Add(con);
    } insert Contacts;
    update relatedContacts;
        }
        
    }
    
    
}
I have created a VF page which has a command link that take me to my desired link but there is istdp p1 at the end of the URL which I dont want. Thank you in advance.

<apex:page controller="TechnologyProduct"  lightningStylesheets="true" showHeader="false" sidebar="false" applyBodyTag="false" applyHtmlTag="false">

    <div id="wrapper">
     <apex:repeat value="{!TechnologyProduct}" var="res" id="repeat">
            <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>
Apex Class that is not getting covered in Test Class:
public with sharing class AskHR_PurgeCaseFiles implements Schedulable{
      
    public Set<Id> CaseId = new Set<Id>();
    public Map<Id, Case> caseDetails = new Map<Id, Case>();
    public static string groupName = 'AskHR_Purging_Case_Attachment_Group';
    public  List<ContentDocumentLink> attachmentList = new List<ContentDocumentLink>();
    public Map<Id, ContentDocumentLink> contentMap = new Map<Id, ContentDocumentLink>();
      public List<Id> CDID = new List<Id>();
   
    public void execute(SchedulableContext sc) {
        performOperation();
    }
   
    public void performOperation() {
       
        if(!Test.isRunningTest()){
           
              attachmentList = [SELECT ContentDocumentId, ContentDocument.Title, ContentDocument.FileType, LinkedEntityId, ContentDocument.isDeleted  FROM ContentDocumentLink where
                              isDeleted=false and LinkedEntityId in
                              (Select Id from Case where Status = 'Closed'and ClosedDate < Last_N_Days:14
                               and Type = 'HR Reporting')
                              limit 1000];
           
             /*attachmentList = [SELECT ContentDocumentId, ContentDocument.Title, ContentDocument.FileType, LinkedEntityId  FROM ContentDocumentLink where
                              LinkedEntityId in
                              (Select Id from Case where Status = 'Closed' and Type = 'HR Reporting')
                              limit 1000];
            attachmentList = [SELECT ContentDocumentId, ContentDocument.Title, ContentDocument.FileType, LinkedEntityId  FROM ContentDocumentLink where
                              LinkedEntityId in
                              (Select Id from Case where status != 'closed')];
            System.debug('AttachmentList: '+attachmentList); */
        }
        else{
           
            attachmentList = [SELECT ContentDocumentId, ContentDocument.Title, ContentDocument.FileType, LinkedEntityId, ContentDocument.isDeleted  FROM ContentDocumentLink where
                             isDeleted=false and LinkedEntityId in
                              (Select Id from Case where Status = 'Closed'and Type = 'HR Reporting' )
                              limit 1000];
        }
        system.debug('attachmentList count ='+attachmentList.size());
        System.debug('Debug CDID Size: '+ CDID.size());
        System.debug('Debug CaseId Size'+ CaseId.size());
       
        if (!attachmentList.isEmpty()) {
        //Get the Case detail
            System.debug('Debug Initial CDID Size: '+ CDID.size());
            System.debug('Debug Initial CDID Data'+ CDID);
            CDID.clear();
            System.debug('Debug CDID set to Zero:'+CDID.size());
            System.debug('Debug Initial CaseId Size'+ CaseId.size());
            System.debug('Debug Initial CaseId Data'+ CaseId);
            CaseId.clear();
            System.debug('Debug CaseId set to Zero:'+CaseId.size());
           
           
            for(ContentDocumentLink cdl : attachmentList){
                System.debug('ContentDocumentId: '+cdl.ContentDocumentId);
                CaseId.add(cdl.LinkedEntityId);
                contentMap.put(cdl.ContentDocumentId, cdl);//cdl.id
                        CDID.add(cdl.ContentDocumentId);//cdl.id
            }
            caseDetails = getCaseDetails(CaseId);
            System.debug('Debug CaseId Size after adding caseids:'+ CaseId.size());
            System.debug('Debug CaseId data after adding caseids:'+ CaseId);
            System.debug('Debug CDID Before Delete: '+ CDID.size());
            System.debug('Debug CDID Data Before Delete'+ CDID);
            //List<ContentDocument> CDIDList = select title,fileType, isDeleted from ContentDocument Where isDeleted=false and id in :=cdid;
         /*   List<ContentDocument> docsList = [select id, Title, FileType, isDeleted from ContentDocument where id in:CDID];
            for(ContentDocument doc: docsList){
                  system.debug('Document: '+doc);
            } */
            /*List<contentDocument> deletedDocuments = new List<contentDocument>([SELECT Id from contentDocument where isDeleted = true]);
            Database.emptyRecycleBin(deletedDocuments);*/
            Database.DeleteResult[] results = Database.delete(CDID, false);
            Database.emptyRecycleBin(CDID);
            System.debug('Debug results After Delete: '+ results.size());
            List<String> operationResults = new List<String> ();
            operationResults.add(createHTMLTable());

            Integer loopIndex = 0;
            Integer countFailedOperation = 0;
           
            for (loopIndex = 0; loopIndex < results.size(); loopIndex++) {
                Database.DeleteResult dr = results.get(loopIndex);
                Id CID = CDID.get(loopIndex);
                String operationResult;
               
                operationResult = '<tr><td>' + caseDetails.get(contentMap.get(CID).LinkedEntityId).CaseNumber + '</td>' +
                    '<td>' + caseDetails.get(contentMap.get(CID).LinkedEntityId).Owner.Name + '</td>' +
                    '<td>' + caseDetails.get(contentMap.get(CID).LinkedEntityId).Type + '</td>' +
                    '<td>' + caseDetails.get(contentMap.get(CID).LinkedEntityId).ClosedDate + '</td>' +
                    '<td>' + contentMap.get(CID).ContentDocument.Title + '</td>' +
                    '<td>' + contentMap.get(CID).ContentDocument.FileType + '</td>';
               
                if (!dr.isSuccess()) {
                    operationResult += '<td>Failed-';
                    for (Database.Error err : dr.getErrors()) {
                        operationResult += 'Details: ' + err.getStatusCode() + '<br/>' + err.getMessage();
                    }
                    operationResult += '</td>';
                    countFailedOperation++;
                } else {
                    operationResult += '<td>Success</td>';
                }
               
                operationResult += '</tr>';
                operationResults.add(operationResult);
            }
            //End for========
            operationResults.add('</table>');
            system.debug('operationResult'+operationResults);
            if (!operationResults.isEmpty()) {
                Integer successOperation = results.size() - countFailedOperation;
                operationResults.add(0, '<b>ASKHR- Purging Case Attachment Job Result: </b><br/>' +
                                     'Success: ' + successOperation + '<br/>' +
                                     'Fail: ' + countFailedOperation + '<br/><br/>' +
                                     'Please see below Files deleted from HR reporting cases closed 14 days ago,<br/><br/>');
                system.debug('Sending Email---');
                sendHTMLEmailNotification('ASKHR- Case File Purging Job ', string.join(operationResults, '\n'));
                system.debug('Email sent---');
            }
           
        }
    }
   
    public string createHTMLTable() {
        return '<table border="1"><tr><th>CaseNumber</th><th>CaseOwner</th><th>CaseType</th><th>ClosedDate</th><th>FileName</th><th>FileType</th><th>Result</th></tr>';
    }
   
   
    public Map<Id, Case> getCaseDetails(Set<Id> ids){
       
       Map<Id, Case> caseMap = new Map<Id, Case>([Select Id, Type, CaseNumber,Owner.Name, ClosedDate from Case where Id in :ids and isDeleted=false]);
        return caseMap;
    }
   
    public static void sendHTMLEmailNotification(String action, String htmlMessage) {
        try {
           
            if(String.isEmpty(action) || String.isEmpty(htmlMessage)){
                throw new NotificationUtilException('Action or Email message is empty');
            }
           
            emailOperation(getAddresses(), action, htmlMessage, true);
           
           
        } catch(Exception e) {
            System.debug('Error occur when attempting to notify html error:' + e.getMessage());
        }
    }
   
   
    public static List<String> getAddresses() {
        List<Group> groups = [select(select UserOrGroupId from GroupMembers) from Group where DeveloperName = :groupName];
       
        if(groups.isEmpty()){
            throw new NotificationUtilException('Could not find the public group ' + groupName + ' when attempting to notify error.');
        }else{
           
            List<String> userIds = new List<String> ();
            List<String> addresses = new List<String> ();
            Group g = groups.get(groups.size()-1);
            for (GroupMember gm : g.GroupMembers) {
                userIds.add(gm.UserOrGroupId);
            }
           
            User[] users = [select Email from User where Id in :userIds];
           
            for (User u : users) {
                addresses.add(u.Email);
            }
            return addresses;
        }
    }
   
    public static void emailOperation(List<String> addresses, String action, String message, Boolean isHTML) {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(addresses);
        mail.setSubject(getSandboxName() + action);
        if (isHTML) {
            mail.setHTMLBody(message);
        } else {
            mail.setPlainTextBody(message);
        }
        //avoid sending emails in Unit Testing to governor limit error
        if (!Test.isRunningTest()) {
            Messaging.sendEmail(new Messaging.Email[] { mail }, false);
        }
    }
   
    public static String getSandboxName() {
        try {
            Organization org = [select id, IsSandbox from Organization];
            if (org.IsSandbox) {
                if (UserInfo.getUserName().substringAfterLast('.com') != null)
                    return '[' + UserInfo.getUserName().substringAfterLast('.').toUpperCase() + '] ';
            }
        } catch(Exception ex) {
        }
       
        return '';
    }
   
     public class NotificationUtilException extends Exception{}
}

Test Class for the above class:
 
@isTest(SeeAllData = true)
public class AskHR_PurgeCaseFilesTest {

     public static Map<String, Schema.RecordTypeInfo> rtMap = Schema.SObjectType.Case.getRecordTypeInfosByName();
   
    static testMethod void testmethod1() {
       
        Case testCase = new Case(External_Contact_Name__c = 'TEST EXTERNAL NAME',
                                Secondary_Country_of_Reference__c = 'USA', Type = 'HR Reporting', Status = 'Closed',
                                RecordTypeId=ASKHR_TestUtility.GetRecordTypeID(ASKHR_Common.CASE_RECORD_TYPE_NAME_GENERAL_HR));
            insert testCase;
       
        ContentVersion contentVersion = new ContentVersion(
            Title = 'Test',
            PathOnClient = 'Test.jpg',
            VersionData = Blob.valueOf('Test Content'),
            IsMajorVersion = true
        );
        insert contentVersion;
       
        List<ContentDocument> documents = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument];
        List<Id> CDID = new List<Id>();
        //create ContentDocumentLink  record
        ContentDocumentLink cdl = New ContentDocumentLink();
        cdl.LinkedEntityId = testCase.id;
        cdl.ContentDocumentId = documents[0].Id;
        cdl.shareType = 'V';
        insert cdl;
       
        CDID.add(cdl.id);    
        CDID.clear();
        Database.DeleteResult[] results = Database.delete(CDID, false);
       
        Delete cdl;
       
        String action = 'Test Action';
        String htmlMessage = 'Html Messages';
        List<Case> cse = [select id from case];
        set<id> ids = new set<id>();
        for(case c : cse){
            ids.add(c.id);
        }
        Test.startTest();
        AskHR_PurgeCaseFiles purgeJob = new AskHR_PurgeCaseFiles();
        AskHR_PurgeCaseFiles.getAddresses();
        purgeJob.createHTMLTable();
        AskHR_PurgeCaseFiles.getSandboxName();
        purgeJob.performOperation();
        purgeJob.getCaseDetails(ids);
        AskHR_PurgeCaseFiles.sendHTMLEmailNotification(action, htmlMessage);
        purgeJob.execute(null);
        Test.stopTest();
    }

}

 
I am facing an issue with fetching the path of image stored in documents (available for external user). 

When the visualforce page is rendered the image shows broken upon inspecting the element it does not capture URL generated from String variable "imageURL". 

Here I am trying to adjust the URL based of image because of enhanced domains release update.

Please suggest as what I may be doing wrong. 

Class: 
public class BBH_Survey {
    public boolean hidecmtbtn{get;set;}
    public boolean modibtn {get;set;} //
    Public String CasId;
    Public String Survey_comments {get;set;} 
    public boolean flag{get;set;}
    public list<BBH_Surveys__c> lstbbhsury;
    public Decimal survyeExpired {get;set;}
    public String btncss{get;set;}
    public String ratingCss{get;set;}
   // Public New_Surveys__c surveyName {get;set;}//
   // public String modifySurvey{get;set;}//
    public string surveyId;
    public String imageURL{get;set;}//
    //public String modiRes {get;set;}//
        
    public BBH_Survey(apexPages.StandardController std) 
    {
        // fetch instance Id : NA169.. etc
        String instanceName = [select InstanceName from Organization limit 1].InstanceName; 
        hidecmtbtn=true;
        Survey_comments='';
        flag=false;
        CasId=ApexPages.currentPage().getParameters().get('CaId'); 
        surveyId = Apexpages.currentPage().getParameters().get('id');
        lstbbhsury=[select id from BBH_Surveys__c where CaseId__c =:CasId]; 
        
        List<New_Surveys__c> schoolsurvey =[select Rating_Css__c,Button_css__c,Survey_Expired__c,School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId]; 
        
        if(schoolsurvey.size()>0){      
       
       // String orgid='&oid=00Dd0000000dwdA';
         Organization organizationInfo = [Select id from Organization];
         string organizationId= organizationInfo.id; 
         String orgid='&oid='+organizationId;
            
         survyeExpired=schoolsurvey[0].Survey_Expired__c;
         btncss=schoolsurvey[0].Button_css__c;  
         ratingCss=schoolsurvey[0].Rating_Css__c;
         
         // fetch baseURL & convert to respect Enhanced domain changes
         
         string baseURL = URL.getSalesforceBaseUrl().toExternalForm() +'/'; 
         string baseimageURL;
         // target Sanbdbox envoirnment
         
         if (baseURL.contains('sandbox.my.salesforce.com')){
         baseURL=baseURL.replace('sandbox.my.salesforce.com', 'sandbox.my.salesforce-sites.com');
         baseimageURL=baseURL.replace('sandbox.my.salesforce-sites.com', 'sandbox.file.force.com');
        
         }
         
         // target Production envoirnment 
         
         else if (baseURL.contains('ceai.my.salesforce.com')){
         baseURL=baseURL.replace('ceai.my.salesforce.com', 'ceai.my.salesforce-sites.com');
         baseimageURL=baseURL.replace('ceai.my.salesforce-sites.com', 'ceai.file.force.com');
         }
         system.debug(' baseURL  :' +baseURL);
         system.debug(' imageURL  :' +baseimageURL);   
         
     // imageURL='Https://ceai--c.'+instanceName+'.content.force.com/servlet/servlet.ImageServer?id='+schoolsurvey[0].School_Logo__c+orgid;
        imageURL=baseimageURL+'/servlet/servlet.ImageServer?id='+schoolsurvey[0].School_Logo__c+orgid;
        } 
        else {
        system.debug('Error in fetching School survey record configuration, check if the New Survey record is created');
        }
        
            
     linkExpire();
    
    }  
    
    Public  PageReference survey_1(){
        
        try{ 
            
            List<case> lstCase=[select id,status ,Survey_fill__c from case where id =:CasId]; 
            List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];            string url=schoolsurvey[0].School_URL__c;
            PageReference myVFPage = new PageReference(url);
            BBH_Surveys__c bbh=new BBH_Surveys__c();
            
            if(lstCase.size()>0)
            {
            bbh.CaseId__c=lstCase[0].id;
            }
               bbh.Survey_Response__c= '1';
               bbh.Surveys_Name__c=surveyId;    
               bbh.Survey_Comments__c =Survey_comments;
        
              insert bbh;
             myVFPage.setRedirect(true);
              return myVFPage; 
        } 
        catch(Exception e)
        { return null; }
            
    }
        

    
Public  PageReference survey_2(){
    
  
    try{
    List<case> lstCase=[select id,status ,Survey_fill__c from case where id =:CasId];
    List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        
        string url=schoolsurvey[0].School_URL__c;
        PageReference myVFPage = new PageReference(url);
        BBH_Surveys__c bbh=new BBH_Surveys__c();
          if(lstCase.size()>0)
            {
            bbh.CaseId__c=lstCase[0].id;
            }
               bbh.Survey_Response__c= '2';
               bbh.Surveys_Name__c=surveyId;    
        	   bbh.Survey_Comments__c =Survey_comments;
        
              insert bbh;
              myVFPage.setRedirect(true);
              return myVFPage;
        } 
       catch(Exception e) {        
       return null;
        }
 }
        

    Public  PageReference survey_3(){
  
    try{
    List<case> lstCase=[select id,status ,Survey_fill__c from case where id =:CasId];
    List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        // PageReference myVFPage = page.Survey_saved;
        string url=schoolsurvey[0].School_URL__c;
        PageReference myVFPage = new PageReference(url);
              BBH_Surveys__c bbh=new BBH_Surveys__c();
               if(lstCase.size()>0)
            {
            bbh.CaseId__c=lstCase[0].id;
            }
               bbh.Survey_Response__c= '3';
               bbh.Surveys_Name__c=surveyId;    
               bbh.Survey_Comments__c =Survey_comments;
        
              insert bbh;
             myVFPage.setRedirect(true);
             return myVFPage;
        } 
        catch(Exception e) 
        {return null;}
            
    }
    

    
    Public  PageReference survey_4(){
      
    try{
    List<case> lstCase=[select id,status ,Survey_fill__c from case where id =:CasId];
    List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        // PageReference myVFPage = page.Survey_saved;
        string url=schoolsurvey[0].School_URL__c;
        PageReference myVFPage = new PageReference(url);
              BBH_Surveys__c bbh=new BBH_Surveys__c();
               if(lstCase.size()>0)
            {
            bbh.CaseId__c=lstCase[0].id;
            }
               bbh.Survey_Response__c= '4';
               bbh.Surveys_Name__c=surveyId;    
               bbh.Survey_Comments__c =Survey_comments;
      
              insert bbh;
                 
             myVFPage.setRedirect(true);
                   
              return myVFPage;
        } catch(Exception e) 
        { return null; }
            
    }
        
    public  PageReference survey_5()
    {
        
     try{
    List<case> lstCase=[select id,status ,Survey_fill__c from case where id =:CasId];
    List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        // PageReference myVFPage = page.Survey_saved;
        string url=schoolsurvey[0].School_URL__c;
        PageReference myVFPage = new PageReference(url);
              BBH_Surveys__c bbh=new BBH_Surveys__c();
               if(lstCase.size()>0)
            {
            bbh.CaseId__c=lstCase[0].id;
            }
               bbh.Survey_Response__c= '5';
               bbh.Surveys_Name__c=surveyId;    
               bbh.Survey_Comments__c =Survey_comments;
      
              insert bbh;
                 
             myVFPage.setRedirect(true);
                   
              return myVFPage;
        } catch(Exception e) 
        { return null; }
            
}
     
 
   public PageReference modifyResponce1() 
    {
     List<BBH_Surveys__c> BBHSurList =[select id,Survey_Response__c from BBH_Surveys__c where CaseId__c=:CasId limit 1];
         List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        // PageReference myVFPage = page.Survey_saved;
        string url=schoolsurvey[0].School_URL__c;   
       PageReference myVFPage = new PageReference(url);  
       BBH_Surveys__c bbt=new BBH_Surveys__c();
        if(BBHSurList.size()>0)
        {
        bbt.id=BBHSurList[0].id;
        }   
        bbt.Survey_Response__c='1';
        update bbt;
        myVFPage.setRedirect(true);
        return myVFPage;
    }
        
        public PageReference modifyResponce2() 
    {
     List<BBH_Surveys__c> BBHSurList =[select id,Survey_Response__c from BBH_Surveys__c where CaseId__c=:CasId limit 1];
         List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        // PageReference myVFPage = page.Survey_saved;
        string url=schoolsurvey[0].School_URL__c;   
       PageReference myVFPage = new PageReference(url);  
       BBH_Surveys__c bbt=new BBH_Surveys__c();
        if(BBHSurList.size()>0)
        {
        bbt.id=BBHSurList[0].id;
        }   
        bbt.Survey_Response__c='2';
        update bbt;
        myVFPage.setRedirect(true);
        return myVFPage;
    }
        
        public PageReference modifyResponce3() 
    {
     List<BBH_Surveys__c> BBHSurList =[select id,Survey_Response__c from BBH_Surveys__c where CaseId__c=:CasId limit 1];
         List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        // PageReference myVFPage = page.Survey_saved;
        string url=schoolsurvey[0].School_URL__c;   
       PageReference myVFPage = new PageReference(url);  
       BBH_Surveys__c bbt=new BBH_Surveys__c();
      if(BBHSurList.size()>0)
        {
        bbt.id=BBHSurList[0].id;
        }   
        bbt.Survey_Response__c='3';
        update bbt;
            myVFPage.setRedirect(true);
        
        return myVFPage;
    }
        
        public PageReference modifyResponce4() 
       {
     	 List<BBH_Surveys__c> BBHSurList =[select id,Survey_Response__c from BBH_Surveys__c where CaseId__c=:CasId limit 1];
         List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        
           // PageReference myVFPage = page.Survey_saved;
           string url=schoolsurvey[0].School_URL__c;   
           PageReference myVFPage = new PageReference(url);  
           BBH_Surveys__c bbt=new BBH_Surveys__c();
       
           if(BBHSurList.size()>0)
           {
             bbt.id=BBHSurList[0].id;
           }   
        bbt.Survey_Response__c='4';
        update bbt;
            myVFPage.setRedirect(true);
        
        return myVFPage;
    }
        
        public PageReference modifyResponce5() 
        {
         List<BBH_Surveys__c> BBHSurList =[select id,Survey_Response__c from BBH_Surveys__c where CaseId__c=:CasId limit 1];
         List<New_Surveys__c> schoolsurvey =[select School_URL__c,School_Logo__c from New_Surveys__c where id=:surveyId];               
        // PageReference myVFPage = page.Survey_saved;
         string url=schoolsurvey[0].School_URL__c;   
          PageReference myVFPage = new PageReference(url);  
          BBH_Surveys__c bbt=new BBH_Surveys__c();
       
            if(BBHSurList.size()>0)
             {
              bbt.id=BBHSurList[0].id;
             }   
        bbt.Survey_Response__c='5';
        update bbt;
        myVFPage.setRedirect(true);
        
        return myVFPage;
    }
    
    
    public  void linkExpire()
    { 
         DateTime dT = System.now();
         Date myDate = date.newinstance(dT.year(), dT.month(), dT.day());
        
             for(case cs:[select ClosedDate from case where id=:casId])
             {
             if(cs.ClosedDate+survyeExpired<myDate)
               {
                 ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Survey link has been expired'));  
                 modibtn=false;
                 hidecmtbtn=false;
           
               }
     
          else if(lstbbhsury.size()>0)
           {
           ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'We see survey is already filled for the ticket. To modify responses, rate the call and click update survey'));
             modibtn=true;
             hidecmtbtn=false;
           }        
         }
    }   
}
Upon inspecting the element User-added image
 
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