• RituSharma
  • PRO
  • 2084 Points
  • Member since 2020

  • Chatter
    Feed
  • 60
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 424
    Replies
I am trying to fetch PublicGroups having '(single quote) in its name using query : select Id from Group where (Name = 'AMER SDR's Group') AND Group.Type='Regular'
but query gets failed on soap ui as well as developer console with error :
from Group where (Name = 'AMER SDR's Group') AND Group.Type='Regular'
^ERROR at Row:1:Column:45
expecting a right parentheses, found 's'

Escaping ' with ' not worked 
Hi All,

I am receiving above error in below code
global class RetrieveMedicalInquiryStatusBatchMVN implements Database.Batchable<sObject>, Database.AllowsCallouts, Database.Stateful, Schedulable {

    String query = 'SELECT Id,Account_vod__c, Status_vod__c, MA_Response_AZ__c ' +
                    // Query Closing
                    'FROM Medical_Inquiry_vod__c ' +
                    'WHERE Sent_to_GMIP_MVN__c = TRUE ' +
                    'AND Id IN :Ids';

    List <String> statuses;
    List<String> Ids = new List<String>('a0tU000000784Gbdue' , 'a0tU00000090WERThc') ;

Can you please help me in sorting this out

Thanks,
Monisha
I want to find specific contact using on the basis of email or phone number
How can we fetch Account data using standard rest APIs?
  • November 16, 2020
  • Like
  • 0
Test__c trigObj = trigger..get(Test.id);
if(trigObj = null){
trigObj.addError('Cloned record should not have the same period as that of Parent record');
}

I am using this code not getting the output as excepted.
Hi all,

I have a picklist that has names (text) that are the same as my contact names (Appointment_with__c)

I have a lookup field to contact that I want to autofill whenever a name is selected from my picklist. The lookup field is called (Staff__c)

I made a basic trigger but encountering silly errors and perhaps not the best code as I am a beginner:

trigger Autofill on Event (before insert, before update) {
    
    Set<String> ids = new Set<String>();
    
    for(Event evt: Trigger.New)
    {
        if(evt.Appointment_with__c != null)
        {
            ids.add(evt.Appointment_with__c);
        }
    }
    
    List<Staff__c> dclocation = [SELECT Id, Name FROM Staff__c WHERE Name in: ids];
    
    for(Event evt1: Trigger.New)
    {
        evt1.Staff__c = dclocation[0].id;
    }
}

I keep getting 'Invalid type: Staff__c'
Variable does not exist: id'
Hello, I have created a package for clients to download. It contains campaigns with influence opportunities reports. Clients are receiving this error:

1. (ReportsforPackage/Campaigns_with_Influenced_Closed_Opps) ReportType: CustomizableCampaignInfluence is not available
ReportsforPackage/Campaigns_with_Influenced_Closed_Opps: ReportType: CustomizableCampaignInfluence is not available
2. (ReportsforPackage/Campaigns_with_Influenced_Open_Opps) ReportType: CustomizableCampaignInfluence is not available
ReportsforPackage/Campaigns_with_Influenced_Open_Opps: ReportType: CustomizableCampaignInfluence is not available

I thought it was because they didn't have campaign influence turned on in their instance, but they do. What else could it be?
Dear Gurus,

How to make 64%  to 100% code coverage for Test class for Batchable to insert records, iterate over the results, and persist information about any failures to the database

Here is class
global class ertnoonbatch3pm implements Database.Batchable<sObject> {
         global Database.QueryLocator start(Database.BatchableContext BC) {
        // collect the batches of records or objects to be passed to execute
        
        String query = 'select Case__c, Level_1__c, Level_2__c,Level_3__c  FROM ERT_Case_Type__c';
        System.debug('ERT Case No is =====>' +query);
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<ERT_Case_Type__c> exeList) {
        
        // process each batch of records
        List<Case_Type__c> listCTD = new List<Case_Type__c>();
        System.debug('ERT Case No is =====>' +exeList);
        for(ERT_Case_Type__c exe : exeList)
        {        
            listCTD.add(new Case_Type__c(Case__c=exe.Case__c,Level_1__c=exe.Level_1__c,Level_2__c=exe.Level_2__c,Level_3__c=exe.Level_3__c));
            // System.debug('ERT Case No is =====>' +Case__c);
        }

        System.debug('ERT Case No is =====>' +listCTD);
        insert listCTD;
        
        
        Database.SaveResult[] srList = Database.insert(listCTD, false);
        
        // Iterate through each returned result
        for (Database.SaveResult sr : srList) {
            if (sr.isSuccess()) {
                // Operation was successful, so get the ID of the record that was processed
                System.debug('Successfully inserted Case_Type__c: ' + sr.getId());
            }
            else {
                // Operation failed, so get all errors                
                for(Database.Error err : sr.getErrors()) {
                    System.debug('The following error has occurred.');                    
                    System.debug(err.getStatusCode() + ': ' + err.getMessage());
                    System.debug('Case_Type__c fields that affected this error: ' + err.getFields());
                }
            }
        }            
        
    }   
    
    global void finish(Database.BatchableContext BC) {
        // execute any post-processing operations
    }      

            }

here is test class
@isTest
public class testertnoonbatch3pm{
    static testMethod void testMethod1() 
    {
        List<ERT_Case_Type__c> lstExecutive_RT= new List<ERT_Case_Type__c>();
            Case c = new Case();
        c.Contact_First_Name__c = 'first name';
        c.Contact_Last_Name__c = 'last name';
        c.Address_Line_1__c = 'first name';
        c.Address_Line_2__c = 'first name';
        c.Address_City__c = 'first name';
        c.Address_State__c = 'WA';
        c.Address_Zip__c = '12345';
        c.Home_Phone__c = '123-456-7890';
        c.E_Mail__c = 'abc@abc.com';
        c.hasdevice__c = true;
        c.IMEI__c = 1234567890123.0;
        c.InterestedinTFB__c = true;
        insert c;
        for(Integer i=0 ;i <200;i++)
        {
            ERT_Case_Type__c rt = new ERT_Case_Type__c();
            //5001Q000016wP1BQAU
            rt.Case__c = c.Id;
            rt.Level_1__c ='Customer Service';
            //rt.Level_1__c ='Customer Service'+i;
            rt.Level_2__c ='Customer Care  -  T-Mobile';
            rt.Level_3__c ='Upholding policy - account services';
            system.debug('inserted value'+rt);
           lstExecutive_RT.add(rt); 
            
        
        }
        
        insert lstExecutive_RT;
        
        Test.startTest();

            ertnoonbatch3pm objbatch3pm = new ertnoonbatch3pm();
            
            DataBase.executeBatch(objbatch3pm); 
            
        Test.stopTest();
    }

}

How to make this code100 % code covered ,here are code lines not coveredUser-added image
I have a workflow to send emails but few users are not receiving them. Can there be a problem with the worflow? or something else?
  • November 10, 2020
  • Like
  • 0
I am having an issue populating a map.  When a user saves a record it will have a postal code.  I am trying to determine if there are existing records with the same postal code.  'prod' is always.  How do I determine if other records have the same postal code?
thanks
P
if( Trigger.isInsert){
            Map<String, Product__c>  prodMap = new Map<String, Product__c>
            ([select id,Zip_Code__c,Type__c from Product__c]);
        
            for (Product__c newprod : (List<Product__c>) trigger.New)
            {
                Product__c prod= prodmap.containskey(newprod.Zip_Code__c) ? prodmap.get(newprod.Zip_Code__c) : null; 
                string fieldtype = newprod.Type__c == 'Field' ? 'F' : 'R';
            
                if(prod!= null){
                    string prodname = fieldtype;
                    string postal  = newprod.Zip_Code__c;
                    integer prodnum = prodMap.size()+1;
                    newprod.Name = fieldtype +'_'+ newprod.Zip_Code__c +'_'+ prodnum;  
                }
            }
        }

 
I have a requirement to send email on deletion of a record. What's the best way to achieve this?
  • November 10, 2020
  • Like
  • 0
Hi Gurus,

Need a Test class for Batchable class with database.insert function then saves the results and iterate through each results 
 
global void execute(Database.BatchableContext BC, List<ERT_Case_Type__c> exeList) {
						
						// process each batch of records
						List<Case_Type__c> listCTD = new List<Case_Type__c>();
						System.debug('ERT Case No is =====>' +exeList);
						for(ERT_Case_Type__c exe : exeList)
						{        
							listCTD.add(new Case_Type__c(Case__c=exe.Case__c,Level_1__c=exe.Level_1__c,Level_2__c=exe.Level_2__c,Level_3__c=exe.Level_3__c));
							// System.debug('ERT Case No is =====>' +Case__c);
						}

						System.debug('ERT Case No is =====>' +listCTD);
						insert listCTD;
						
						
						Database.SaveResult[] srList = Database.insert(listCTD, false);
						
						// Iterate through each returned result
						for (Database.SaveResult sr : srList) {
							if (sr.isSuccess()) {
								// Operation was successful, so get the ID of the record that was processed
								System.debug('Successfully inserted Case_Type__c: ' + sr.getId());
							}
							else {
								// Operation failed, so get all errors                
								for(Database.Error err : sr.getErrors()) {
									System.debug('The following error has occurred.');                    
									System.debug(err.getStatusCode() + ': ' + err.getMessage());
									System.debug('Case_Type__c fields that affected this error: ' + err.getFields());
								}
							}
						}            
						
					}   
					
					global void finish(Database.BatchableContext BC) {
						// execute any post-processing operations
					}
				}

 
I need to retrieve the Account id and insert it to my method. Get the Basket__r.Account__r.id and place it to the Account id inside the for loop. How can i do that?
 
list<Configuration__c> conf = [select id, name, Basket__r.id, Basket__r.Account__r.id  from Configuration__c where Basket__r.id = : basketId];
    
    
    for (Configuration__c confList: conf){
    
    Attachment att = [select id, body from Attachment where name like parentId = :confList.id];
    system.debug(att);
    system.debug(att.Body);
    system.debug(att.Body.toString()); 
    list <Guarantee_Line__c> guara = new list <Guarantee_Line__c>();
    
    guara = GuaranteeCreator.createGuarantee(att.Body.toString(), confList, Account id);
    }

 
On creation of a record I need to update its name based on a value on existing records.
For example a new record is created and the code Id is 12345
If a record exist with this value I need to set the new record code Id to 12345_001.  This will continue so if the latestcode ID value is 12345_054 the new code Id needs to be 12345_055
So how do I search for this value and set the new one?   Will this be an issue on data loads?
Thanks,
P​​​​​​​  
Hello All,
Need some help creating a process for creating an object name.  So the name will be a text value plus an auto incremetnted value.
For example Opportunity created would be 'Test_001 '
But what if the count is up to Test_089 and they need to delete 5 opportunities and the opportunities are in different sequences?  So they need to delete Test_055 and Test_041 and Test_020.  The naming needs to stay in sequencial order.  Is this possible?
How do I handle the naming when they do a data load?   
Thanks,
P
We have multiple action buttons (images) on a page based on formula fields  . Click on any action button should check whether the current user has edit access to the record . If current user has read only access, display error message, otherwise proceed with existing action button functioanlity . There are several action buttons in a page and same logic should be applied for all . What is the best way to implement this ?
 
Hi,

Here is my current Batchable apex code,currently this batch job  copies the data over from the new custom object ERT_Case_Type__c to the old custom object Case_Type__c 

But problem is this job failing where the Level1, Level2 or Level3 are not there.   

This is due to the old picklist restricting based on what values we had in the old picklist on these 3 fields...so I have removed that restriction on the 3 Level fields in Case Type
 
 How can i make sure that Batchable Salesforce apex code  shouldn't be failing where the Level1, Level2 or Level3 are not there.   
 
global class ertcopybatch3pm implements Database.Batchable<sObject> {
				  
					global Database.QueryLocator start(Database.BatchableContext BC) {
						// collect the batches of records or objects to be passed to execute
						
						String query = 'select Case__c, Level_1__c, Level_2__c,Level_3__c  FROM ERT_Case_Type__c';
						System.debug('ERT Case No is =====>' +query);
						return Database.getQueryLocator(query);
					}
					
					global void execute(Database.BatchableContext BC, List<ERT_Case_Type__c> exeList) {
					   
						// process each batch of records
				List<Case_Type__c> listCTD = new List<Case_Type__c>();
						System.debug('ERT Case No is =====>' +exeList);
						for(ERT_Case_Type__c exe : exeList)
						{        
							 listCTD.add(new Case_Type__c(Case__c=exe.Case__c,Level_1__c=exe.Level_1__c,Level_2__c=exe.Level_2__c,Level_3__c=exe.Level_3__c));
						   // System.debug('ERT Case No is =====>' +Case__c);
						}
						try {
						  System.debug('ERT Case No is =====>' +listCTD);
							insert listCTD;
						
						} catch(Exception e) {
							System.debug(e);
						}
						
					}   
					
					global void finish(Database.BatchableContext BC) {
					  // execute any post-processing operations
				  }
				}

Thanks in advance,
Fiona​​​​​​​
I have a requirement to allow community users to login using Linkedin credentials. How can i achieve this?
Hello, 

I need to create records based on a JSON. The problem right now is that the key value of the JSON contains white spaces, so the deserialization comes with null values. How can i deal with that? 
 
public class GuaranteeJSON {
    
    public List<Configurations> configurations;
    
    public class Configurations {
		public String guid;
		public String Guarantee Type;
		public String Guarantee Amount;
		public String In Advance Amount;   
}
    public static GuaranteeJSON parse(String json) {
		return (GuaranteeJSON) System.JSON.deserialize(json, GuaranteeJSON.class);
	}
}

 
I have created and updated a few Contacts and have also encoded start and end parameters
Following is my REST call
GET https://xxx.xxx.xxx/services/data/v49.0/sobjects/Contact/updated?start=2020-11-01T00%3A00%3A00%2B05%3A30&end=2020-11-06T14%3A56%3A00%2B05%3A30

But I keep getting 
[
    {
        "errorCode": "NOT_FOUND",
        "message": "The requested resource does not exist"
    }
]
What am I missing here ?

Thanks
Suhel

 
I have Account, Opportunity and Application Object.
Application is child to account, Application has picklist field status__c
if, Application Statas__c ='inProgress' , Account and Opportunity records should get locked, 
if status=='InProgress' records should get unlock.
I am trying to fetch PublicGroups having '(single quote) in its name using query : select Id from Group where (Name = 'AMER SDR's Group') AND Group.Type='Regular'
but query gets failed on soap ui as well as developer console with error :
from Group where (Name = 'AMER SDR's Group') AND Group.Type='Regular'
^ERROR at Row:1:Column:45
expecting a right parentheses, found 's'

Escaping ' with &apos; not worked 
I need to create a field for a salesforce object that holds multiple date/time stamps. Each time an event happens, a date/time stamp will be added to the field. So this field is effectively a list of objects. I am unclear on how to do this. Any suggestions on workflow and specifically what data type this field would be are appreciated.
Hi, 

I'm trying to upgrade a lookup to Lead from a custom object to Master-detail, but the option is not there.
  • This is a custom object
  • There are records already
  • Every record has Lead populated
Thanks 

JUser-added imageUser-added image
Hi All,

I am receiving above error in below code
global class RetrieveMedicalInquiryStatusBatchMVN implements Database.Batchable<sObject>, Database.AllowsCallouts, Database.Stateful, Schedulable {

    String query = 'SELECT Id,Account_vod__c, Status_vod__c, MA_Response_AZ__c ' +
                    // Query Closing
                    'FROM Medical_Inquiry_vod__c ' +
                    'WHERE Sent_to_GMIP_MVN__c = TRUE ' +
                    'AND Id IN :Ids';

    List <String> statuses;
    List<String> Ids = new List<String>('a0tU000000784Gbdue' , 'a0tU00000090WERThc') ;

Can you please help me in sorting this out

Thanks,
Monisha
Hi Team,

When the date is changed or added in the field, Process the Approval process. In Approval process i want to perform the Approval Request, Approval Accepted ,Approval Denied.

how it can be achieved. If it is achieve through Wokflow, please let me know the possible cases.
I have developed a custom Gantt Chart, which i'm displaying in a <table> tag. Now I want to download the Image of the Gantt chart. Is there a way to render it as an image?
I have a requirement to upsert Policy records using JSON response obtained from external system.

below is my apex code:
 
HttpRequest req = new HttpRequest();
  req.setMethod('GET');
  req.setTimeout(120000);
  req.setEndpoint('<endpoint>'); 
  req.setHeader('Authorization', 'Bearer ' + '<bearer token>');
  Http http = new Http();
  HTTPResponse res = http.send(req);
  String response = res.getBody();
JsonParser jsondes = (JsonParser) JSON.deserialize(response, JsonParser.class);

I have a JSON Parser class and it is as follows:
 
public class JSONParser{
    public Integer code;
    public cls_value value;
    public class cls_value {
        public cls_data[] data;
        public String message;
        public Integer code;    
    }
    public class cls_data {
        public String agencyName;
        public String agentID;  
        public string id;   
    }
}


Now, from the above code peice, ID is unique and if the id matches with existing Policy__c's Unique_ID__c field value, the record should be updated. Else, the record should be inserted.

Can anyone please let me know on how to do so.

Thanks!
Hi 

Can anyone help me with the below requirement?

I need to add a condition for updating the records when country value is equal to Singapore of Philippines or if the country value changes then the record should get updated 
I want to find specific contact using on the basis of email or phone number

Hey Admins! How do i add myself to a sandbox?
New Admin here. i cannot refresh a Sandbox and old Admin is gone, any way to get myself into Sandbox without refreshing?
I have a couple questions regarding filtered lookups and LWC. I have a lightning component wrapped in a LWC. On a create page I have a couple filtered lookup fields that are filtered based on values selected on the lightning component create page. I read that filtered lookups are not supported in lightning components and you need a custom lookup component.

So My first question is can I use something like this to resolve my issue: https://sfcure.com/2019/07/06/showing-a-lookup-field-which-respects-with-lookup-filters/

Second. Do I need a separate custom lookup component for each filtered lookup field?
Thanks
P

Need a query that basically says

(ExposeCase = true OR CreatedByID = UserInfo.getUserId()) AND isClosed = false

which would be in the following syntax and sort of a combination of these:

soql += ' Where CreatedById = \'' + UserInfo.getUserId() + '\' OR Expose_Case__c = true';

soql += ' Where Expose_Case__c = true AND isClosed = false';

I am unable to figure out the syntax. I've tried the following 

soql += ' Where CreatedById = \'' + UserInfo.getUserId() + '\' OR Expose_Case__c = true' + 'AND isClosed = false';

We receive from an external system different records that have a field called Serial__C that contains the same value for certain records. 

For example:

Record A: Serial__c = 12345
Record B: Serial__c = 12345

I would liek to create a query that group in a list all the Sobject that have the same value in the Serial__c.
 

Hello,

I've been having some issues getting emails to send when inserting a CaseComment. I'm currently using the nForce npm module as my program is written for use with nodejs.

Some sample code 

const casecoment = nforce.createSObject('CaseComment', {
	CommentBody: 'API-based nForce test for a comment',
	ParentId: cParentId,
	IsPublished,
});

org.insert({
	sobject: casecoment,
	oauth,
}, (err, resp) => {
	if (err) {
		console.log("Could post to case comment");
		console.log(JSON.stringify(err));
	}
	else {
		console.log('posting comment worked!');
	}
});

What I'm wondering is what else I may need to do in order to get emails for case updates to the contact sent out. I'm able to get emails as the case owner without any issues. On the CaseComment sObject page, I saw that "IsNotificationSelected" is a column I can read, but isn't something I can create as I just receive an error when adding it to my code above.

Is there a way to programmatically have the notification email sent out like the "Send Customer Notification" in the website interface?

We have multiple action buttons (images) on a page based on formula fields  . Click on any action button should check whether the current user has edit access to the record . If current user has read only access, display error message, otherwise proceed with existing action button functioanlity . There are several action buttons in a page and same logic should be applied for all . What is the best way to implement this ?