• Jay Guruswamy
  • NEWBIE
  • 85 Points
  • Member since 2016

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 3
    Likes Given
  • 1
    Questions
  • 23
    Replies



How to write testmethod for getDetails() here.
public class addressDetails{

        public String latitude {get;set;}
        public String longitude {get;set;}
        ........
    }
     public addressDetails getDetails(String strAddress)
     {
             Http http = new Http();
            HttpRequest request = new HttpRequest();
         IF (strAddress!=null){
             strAddress=strAddress.replaceAll(' ', '+');
                    addressDetails addr=new addressDetails();
        if (latitude!='') { addr.latitude=latitude;}
        if (longitude!=''){ addr.longitude=longitude;}
        ........................
        System.debug('Value of adddress is here : ' +addr);
        
        return addr;
     }
Hello,
I builded a table with multiple rowspans. It has following structure:

    <table>
      <tr>
        <td rowspan="6">parent column</td>
        <td rowspan="4">column 2 A</td>
        <td rowspan="3">column 3 AA</td>
        <td rowspan="2">column 4 AAA</td>
        <td rowspan="1">column 5 AAAA</td>
      </tr>
      <tr>
        <td rowspan="1">column 5 AAAB</td>
      </tr>
      <tr>
        <td rowspan="1">column 4 AAB</td>
      </tr>
      <tr>
        <td rowspan="1">column 3 AB</td>
      </tr>
      <tr>
        <td rowspan="2">Column 2 B</td>
        <td rowspan="1">Column 3 BA</td>
      </tr>
      <tr>
        <td rowspan="1">Column 3 BB</td>
        <td rowspan="1">Column 4 BBA</td>
      </tr>
    </table>

Now when I will hover over any table detail element I do not want to change the background color of the whole row, but only of the whole Parent - Child relationship.

For Example when I will hover over column 4 AAB, following columns should change the background color: parent column, column 2A, column 3 AA, column 4 AAB.

User-added image
Hi,

I am writing an app using visual studio .net(5.0) C# to integrate with Salesforce.

I used "Connected Services" to include the WSDL generated.

System.Threading.Tasks.Task lr = client.loginAsync(LSHdr, userName, password + securitytoken); works fine

When I try to do a DML(say Upsert), it raises {"UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService"}

Since it is Connected Service(not a Web Service), I could not find SforceService.

Also I could not set any values like SessionId, ServerURL etc(i.e dont know how to set them)

Thoughts please.
I am looking to hire a Salesforce Developer on a contract status. We are looking for a qualified individual, local to the metro-Atlanta, GA area, who can assist with pushing a struggling Salesforce implementation project “across the finish line”.

Our current platform has been given limited attention over the last few years and we need to get it appropriately aligned with our EMR program – NextGen.


Developers with NextGen or healthcare related experience would be greatly appreciated! But we need 100% focus applied to this project - developing the software to implement our "wish list", assist in the development of policy and procedure guidelines, as well as the training of staff members.

Duration of contract is unknown - 90+ days.

If interested, please connect with me via email, including your resume, at pfleck@proco-llc.net

Thank you in advance!
Hi Guys,

I need to change the Time value of the DateTime field to the exact time based on the another filed call time having a picklist AM and PM, if it is AM the time value of DateTime is 10:00:00 else 15:00:00 .Any help will be appreciated.

Thanks
i want my user to redirect to a vf page on clicking a url sent via email . i wwant to place that vf page in communities . its a survey form hence no session logins required . 

could someone please suggest me the approach.
Hi Team,

I am designing my system. The object 1(could be a standard or custom object, not decided yet) is as below,

Object 1

Field 1 --> Picklist
Field 2 --> Picklist
Field 3 --> Picklist
Status  --> Text ( Status is not important while determining count in Object 2)


Object 2
Field 1 --> Picklist
Field 2 --> Picklist
Field 3 --> Picklist
Max count--> Number
TotalCountFrom1--> ??


1) How do I determine the value for TotalCountFrom1 in Object2 from Object 1? Can it be done using out-of-box features of sfdc.com?

2) Whenever a record is added to Object 1 and it makes the TotalCountFrom1 > Max count in Object 2, the status of Object 1 should be set to 'Pending'. When the requestor send for approval process, if approved the Status should be 'Complete' and when rejected the status should be 'Rejected'.
I am planning to use Automation process available in salesforce(Flow Builder) to check Object 2 if TotalCountFrom1 > Max count.

Is the design idea sound? Since the entry in Object 1 is dependent on entry in Object 2 and from point 1 the entry in Object 2 is decided by entry in Object 1, would it lead to a deadlock situation?

Many Thanks in advance!




 
Hi, My apex class is working fine in the sandbox but not firing email in production. I have scheduled job for the apex class in production and sandbox.
here is the code:

global class BirthdayCronJob implements Schedulable{    
      
      //mandatory function called by the Apex Scheduler  
      global void execute(SchedulableContext SC) {  
        sendmail(); // our main function that does the email sending  
      }//end execute()  
    
    
      public void sendMail()   
      {  
        //define variables       
         
        String BirthdayEmailTemplateName = 'Contact_Birthday_Reminder';  
        String debugMessage;  
        String[] toAddresses;  
    
        Integer DayOfEvent  = date.today().day();  
        Integer MonthOfEvent = date.today().month();  
    
    
        // build the Birthday list  
    
        //get the list of people with birthdays - this can justifiably come back empty, on a day when no contacts were born   
       // List<Id> BirthdayIdsList = getBirthdayEmailAddresses(MonthOfEvent,DayOfEvent);  
        
        Contact[] c = [SELECT Id, email, Birthdate, Receive_Birthday_Emails__c  
                FROM Contact   
                WHERE email <> '' AND   
                DAY_IN_MONTH(Birthdate) = : DayOfEvent   
                AND CALENDAR_MONTH(Birthdate) = : MonthOfEvent AND accountid in (select id from account where parentid='0011I00000tF1CfQAK')  
                ];
    
    
        //Set the templates  
        EmailTemplate birthdayTemplate = [select Id,Name,Subject,body from EmailTemplate where DeveloperName = :BirthdayEmailTemplateName];  
        
        //If we have a template, and we have a list of email addresses, then send the email  
       // if(birthdayTemplate != null && BirthdayIdsList.isEmpty() == false) 
        if(birthdayTemplate != null)  
        {  
        
          OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'ari@rastegarproperty.com'];
  
           String[] bccAddresses = new String[] {'ari@rastegarproperty.com'};

            for(Contact recipient : c) {  
                            
                if (recipient.Receive_Birthday_Emails__c == true )  
                {  
                    Messaging.SingleEmailMessage birthdayMail = new Messaging.SingleEmailMessage();  
                     // mailToIds.add(recipient.Id);  // add to email contact array  
                     birthdayMail.setTargetObjectId(recipient.Id);
                     birthdayMail.setTemplateId(birthdayTemplate.Id);
                     birthdayMail.setBccAddresses(bccAddresses);
                    if ( owea.size() > 0 ) {
                        birthdayMail.setOrgWideEmailAddressId(owea.get(0).Id);
                     }
                      try {  
                        //Messaging.sendEmail(new Messaging.MassEmailMessage[] { birthdayMail });  
                        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { birthdayMail });
            
                      }catch(Exception e)  
                      {  
                        System.Debug(e);  
                      }  
          
                     
                } else {  
                  System.Debug('\n*******NO Recipient');  
                }  
                
            }  
              
 
          // Send the email  
         
        }  
        else  
        {  
          System.Debug('BirthdayCronJob:sendMail(): Either an email template could not be found, or no Contact has a birthday today');  
        }//end if  
            
     }//end sendMail()   
      
  }//end class BirthdayCronJob
I have an  api class and have to wite test class but test class  is not covering :

class;
public class fileViewController { 
ApexPages.StandardController controller; 
public Boolean httpErrorReceived {get; set;} 
public String respFileString {get; set;} 
public String contentType {get;set;} 

public fileViewController(ApexPages.StandardController controller){ 
this.controller = controller; 
httpErrorReceived = false; 


public void viewFile(){ 
try{ 
Case req = getPortfolioUrl(); 
if(null !=req.Portfolio_Analysis_Report__c && req.View_checkbox_c){ 
String authorizationHeader = 'Bearer ' + PortfolioAnalysisCallouts.getAuthToken(); 

Http http = new Http(); 
HttpRequest request = new HttpRequest(); 
request.setMethod('GET'); 
request.setHeader('Authorization', authorizationHeader); 
request.setEndpoint(req.Portfolio_Analysis_Report__c); 
system.debug('Request==='+request); 

HttpResponse response = http.send(request); 
system.debug('Response==='+response); 
if(response.getStatusCode()==200 || response.getStatusCode()==202){ 
//respFileString = response.getBody(); 
respFileString = EncodingUtil.Base64Encode(response.getBodyAsBlob()); 
contentType = 'application/pdf'; 
}else{ 
respFileString = 'Connection Failed '; 
contentType = 'text/plain'; 
httpErrorReceived = true; 

}else{ 
respFileString = '\"Analysis Report\" is not available'; 
contentType = 'text/plain'; 
httpErrorReceived = true; 

}catch(Exception e){ 
respFileString = 'Connection Failed:"; 
contentType = 'text/plain'; 
httpErrorReceived = true; 

System.debug('respFileString=='+respFileString); 


private Case getPortfolioUrl() { 
return [select 
Id, 
Portfolio_Analysis_Report__c, 
View_checkbox_c 
from Case 
where Id =: ApexPages.currentPage().getParameters().get('id')]; 

private static String getUrl(){ 
URLParameters__c urls = URLParameters__c.getOrgDefaults();//custom setting 
String url = urls.newVal__c; 
return url; 



Mock class:
@isTest 

global class MockHttpResponseGenerator implements HttpCalloutMock { 

global HTTPResponse respond(HTTPRequest req) { 

System.assertEquals('https://example.com', req.getEndpoint()); 
System.assertEquals('GET', req.getMethod()); 


HttpResponse res = new HttpResponse(); 
res.setHeader('Content-Type', 'application/json'); 
res.setBody('{"test":"test1"}'); 
res.setStatusCode(200); 
return res; 



test class: 
@isTest 
public class ViewPortfolioPDFControllerTest { 
public static testMethod void method1() { 


case con = new case(); 
con.Subject = 'Test Subject'; 
con.Initial_Status__c ='Takeovers'; 
con.status='In Progress'; 
con.Total_Assets__c = 0; 
con.Portfolio_Analysis_Report__c= '/services/apexrest/claimApi'; 
con.View_checkbox_c=true; 
insert con; 

Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator()); 
Test.startTest(); 

apexpages.currentpage().getparameters().put('Cid' , con.Id); 
ApexPages.StandardController sc = new ApexPages.standardController(con); 
ViewPortfolioPDFController vpc= new ViewPortfolioPDFController(sc); 
vpc.viewPortfolioPDF(); 

Test.stopTest(); 
}

can anyone please help
Hi All,

I am getting this below error while upserting the permission set to the user object. I would appreciate someone can provide me with the correct solution. The requirement is to give one common permission to both the users.

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger Addpermission caused an unexpected exception, contact your administrator: Addpermission: execution of AfterUpdate caused by: System.DmlException: Upsert failed. First exception on row 0; first error: DUPLICATE_VALUE, Duplicate PermissionSetAssignment. Assignee: 00546000000aUk8; Permission Set: 0PS46000000IhId: [AssigneeId, PermissionSetId]: Class.userHandler.addPermission: line 44, column 1

Below is the class

Public class userHandler{

Public static void addPermission(List<user>newUser) 
    {
    
    List<PermissionSetAssignment> permissionSetList = new List<PermissionSetAssignment>();
    List<User> userList= [SELECT ID,UserRole.Name,Profile.Name,IsActive FROM User WHERE Profile.Name = 'Solution Manager' or Profile.Name='Marketing User' ];
    for (User u : userList)
    { 
       if(u.Profile.Name=='Solution Manager')
       {
        system.debug(u);
        PermissionSetAssignment psa1 = new PermissionSetAssignment (PermissionSetId = Label.Test, AssigneeId = u.Id);
        permissionSetList.add(psa1);
        PermissionSetAssignment psa2 =new PermissionSetAssignment (PermissionSetId = Label.CRM_Permission_Set, AssigneeId = u.Id);
        permissionSetList.add(psa2);
        }
        
        Else if(u.Profile.Name=='Marketing User')
       {
        system.debug(u);
        PermissionSetAssignment psa3 = new PermissionSetAssignment (PermissionSetId = Label.Test, AssigneeId = u.Id);
        permissionSetList.add(psa3);
        PermissionSetAssignment psa4 =new PermissionSetAssignment (PermissionSetId = Label.Service_Cloud_User, AssigneeId = u.Id);
        permissionSetList.add(psa4);
        }
   
    }
    
  Boolean isinsertfirstTime = true;
  try{  
      upsert permissionSetList;
     }catch (DMLException e) 
     {
     system.debug('exception caught' + e);
     if(isinsertfirstTime)
      {
       upsert permissionSetList;
      }
     }
 }
}
I want to go straight to a solution record type without being need to select the record type. When i check the url i see that opp name it is different than the one from where i started the solution.

Here is my visualforcepage
<apex:page standardController="Solutions__c" recordSetVar="solutions" extensions="SolutionWrapper" >
        
        <script>        
            function redirect(){
                window.location.href='/a0A/e?CF00ND0000005pODo={!opp.Name}&CF00ND0000005pODo_lkid={!opp.Id}&retURL=%2F{!opp.Id}&RecordType=012D00000007LTY&Opportunity__c={!opp.Name}&Solution_Country__c={!sol.Solution_Country__c}={!acc.Country__c}&ent=01ID0000000uXce';
            }
            window.onload = window.setTimeout(redirect(),5000);
        </script>

</apex:page>

Controller :

public with sharing class SolutionWrapper {
    public Opportunity opp{get; set;}
    public Solutions__c oppId{get; set;}
    public Solutions__c sol{get; set;}
    public Solutions__c solution{get; set;}
    public Account acc{get; set;}
  
    public SolutionWrapper(ApexPages.StandardSetController controller) {
        try{
            solution = new Solutions__c();
            solution = (Solutions__c)controller.getRecord();
            if(solution.Id != null){
                oppId = [SELECT id, Solutions__c.Opportunity__c,Mail_Merge_Id__c
                    FROM Solutions__c
                WHERE id =: solution.id
                OR Mail_Merge_Id__c =: solution.Mail_Merge_Id__c 
                LIMIT 1];
                
                opp = [Select id,Name, AccountId, CurrencyIsoCode  from 
                         Opportunity where id =: oppId.Opportunity__c  LIMIT: 1];
            }
            
            if(opp.id !=null){
                sol = [SELECT id,Name, Mail_Merge_Id__c,Solution_Country__c, Solutions__c.Opportunity__c 
            FROM Solutions__c
            WHERE Solutions__c.Opportunity__c =: opp.id
            LIMIT 1];
                 acc = [Select id,Name,Country__c from 
                         Account where id=:opp.AccountId LIMIT: 1];
            }
            
            
        }
        catch(Exception e){
            ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR,e.getMessage()));
        }

    }

}
  • June 19, 2019
  • Like
  • 0
I need help writing a multi IF statement (or) for two separate fields. One field needs to read > 0 (or) check box field = true, (is - generate “this text”, else - generate “this text). Both are custom fields and I’m driving myself crazy bc I keep getting a syntax error. 

Please Help
Hi Folks,

It's my first question in this community, hoping to get some answers on my first question. I was looking into lead assignment rules configuration but I can't figure out a way to validate user's eligibility before lead can be assigned to user agent. It seems like I have to use after trigger on  lead object to assign the leads to eligible agent based on some other criteria. Here is  my scenario. Lead needs to be assigned based on lead and agent territory and this part is easy. But agent should receive the lead only if agent meets some eligibility criteria like agent is licensed and appointed and agent is not OOO etc.

So is it possible to achieve it using lead assignment rules or do I have to write custom code using after trigger on lead object?

 
Hi all,

I'm new to Apex but have been tasked with making one small change to an old Apex Class.
 
public with sharing class WorkDetailUtilities
{
    public static List<SVMXC__Service_Order_Line__c> AddWorkDetails(SVMXC__Service_Order__c WorkOrder, WorkDetailUtilities.FSGCart FSGCart, 
                                Id WorkDetailRTId, List<FSGItemWrapper> MissingCartItems, Id WorkDetailId) 
    {
        system.debug(LoggingLevel.INFO, 'WorkOrder: ' + WorkOrder + ', FSGCart: ' + FSGCart + ', WorkDetailRTId: ' + WorkDetailRTId + ', WorkDetailId: ' + WorkDetailId);
        List<SVMXC__Service_Order_Line__c> WorkOrderLines = new List<SVMXC__Service_Order_Line__c>();
        Map<String, WorkDetailUtilities.FSGItemWrapper> mapPartQuantity = new Map<String, WorkDetailUtilities.FSGItemWrapper>();
        String STDWorkshopHoursProductCode = Label.STD_Workshop_Hours_Product_Code;
        SVMXC__Service_Order_Line__c PSWorkDetail;
        
        try 
        {
            for(WorkDetailUtilities.FSGItemWrapper FSGCartItem :FSGCart.CartItems) 
            {
                system.debug(LoggingLevel.INFO, 'FSGCartItem: ' + FSGCartItem);
                if (FSGCartItem.Part != STDWorkshopHoursProductCode && !FSGCartItem.Part.contains('-'))
                {
                    mapPartQuantity.put('00-' + FSGCartItem.Part, FSGCartItem);
                }
                else
                {
                    mapPartQuantity.put(FSGCartItem.Part, FSGCartItem);
                }    
            }
            system.debug(LoggingLevel.INFO, 'mapPartQuantity: ' + mapPartQuantity);
            
            if (String.isNotBlank(WorkDetailId))
            {
                PSWorkDetail = [SELECT Id, SVMXC__Serial_Number__c, SVMX_Line_Branch_Code__c FROM SVMXC__Service_Order_Line__c WHERE Id =:WorkDetailId];
            }
            system.debug(LoggingLevel.INFO, 'PSWorkDetail: ' + PSWorkDetail);
            
            List<Product2> lstProducts = new List<Product2>([SELECT Id, ProductCode, Name,SVMX_Extra_Description__c,SVMXC__Product_Cost__c FROM Product2 WHERE ProductCode IN :mapPartQuantity.keySet() 
                        AND SMVX_Sales_Company__c =:WorkOrder.SVMXC__Company__r.SVMX_Sales_Company__c AND IsActive = true]);
            system.debug(LoggingLevel.INFO, 'lstProducts: ' + lstProducts);
The change should be (where marked in bold) that instead of '00-' being added it should take the value from the field prefix__c on the Product object. If I add that in instead like: 

mapPartQuantity.put(prefix__c + FSGCartItem.Part, FSGCartItem);

I get the error Error: Compile Error: Variable does not exist: prefix__c at line 19 column 41. 

I guess I need to add that field in somewhere before, but where?

Any help will be much appreciated.
  • June 17, 2019
  • Like
  • 0
Hi there, 

Quiet a few years ago (prior to my time at this company) we had a custom object and a custom button created on it to work with Conga Composer to create an excel from a template. 

Last time I used it about a month ago it was working fine. I just went to use it a few days ago and its no longer working. When I am in Classic mode it seems like its working and says merge complete but doesnt actually download anything 

When I am in lightening it opens a new window with the below error: 
User-added image

I then copied the URL from the button to see what error I would get and got the below: 
User-added image

Currently the Button URL is: 
https://composer.congamerge.com/composer8/index.html 
?sessionId={!API.Session_ID} 
&serverUrl={!API.Partner_Server_URL_80} 
&id={!Variation__c.Id} 
&ReportId=[VarItem]00O90000005hUbP, 
[ReferAndSign]00O90000007biaJ, 
[CoS]00O90000008nQWR?pv0={!Variation__c.Contract_of_SaleId__c} 
&TemplateId=a0M9000000CZz1y 
&DS7=13 
&OFN={!Variation__c.Contract_of_Sale__c}+-+{!Variation__c.Name} 
&OCNR=1

We have other custom buttons with Conga Composa that are working fine, its just this one and it was working previously. 

I have been using Salesforce for a while but never really on the developer side - any ideas on whats suddenly wrong with it would be great! 

Thanks, 
Anne 

 
Hi, i have a VFP rendered as PDF and i would like to dynamically resize the image in my VFP if the image exceed 200px width. if the image width is below 200px, i do not want to stretch the image to 200px, keep it as it is. is that possible?

i tried to set Style = "width 50%" but it will stretch the smaller size image which doesnt look good.



How to write testmethod for getDetails() here.
public class addressDetails{

        public String latitude {get;set;}
        public String longitude {get;set;}
        ........
    }
     public addressDetails getDetails(String strAddress)
     {
             Http http = new Http();
            HttpRequest request = new HttpRequest();
         IF (strAddress!=null){
             strAddress=strAddress.replaceAll(' ', '+');
                    addressDetails addr=new addressDetails();
        if (latitude!='') { addr.latitude=latitude;}
        if (longitude!=''){ addr.longitude=longitude;}
        ........................
        System.debug('Value of adddress is here : ' +addr);
        
        return addr;
     }
What logical operator should work in lightning conditions
Hi All, 

When we open an account in Lightning and click on "Get Survey Invitation", after selecting already created Survey record and clicking on "Generate Invitation" an URL gets created and stored in Survey Invitation object field called "Invitation Link". 

The issue is on the same record of Survey Invitation, I am able to see the url/invitation field value in Lightning view however not in Classic.

Please provide inputs and feedback, how can I see the same in Classic as well.

Best Regards,
Kunal
When a customer tries to log in to our wordpress site, the user  in our system is written over with an incorrect username, that merges our own organization’s salesforce ID with the customer’s email address. The salesforce ID for our organization is 00Dd0000000XXXX, so when a user (for example, johndoe@gmail.com) tries to log in, username 00Dd0000000XXXX@johndoe@gmail.com is created, and the email address assigned is 00Dd0000000XXXX@johndoegmail.com. We can correct the email address and username through our phpadmin, which allows John Doe to log in again, but after he logs in again, the username and email address are again incorrect. This only happens for users that are created through salesforce -- our own internal users aren't affected. We initially thought this was related to incorrect role mapping in our SAML authenticator, miniOrange. We had salesforce "NameID" as what was being mapped to wordpress Username and Email. Initially, it seemed like changing the mapping salesforce "Username" to wordpress Username and Email fixed the issue. The problem is back again, with the weird users being created, whether it's being mapped to "username" or "email." Interested in hearing if anybody has dealt with this problem before. Attached is a screenshot of the log from SAML tracer -- it shows "NameID" but the same issue is happening with "Username" and with "email"screenshot of json file from the SAML tracer log indicating the weird email address