• Supriyo Ghosh 9
  • NEWBIE
  • 40 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 10
    Replies
Hi,

I have written one trigger.

trigger CopyleadvaluetoOpp on Opportunity (after insert) {
   
   Set <String> OppotunityCustId = new Set <String> ();
   
   for(Opportunity Opp : trigger.New)
   {
    OppotunityCustId.add(Opp.Customer_ID__c);
   }

   Map <String, Lead> matchingLeadMap = new Map <String, Lead> ();
   
   for (Lead Ld : [Select Id,Status,Customer_Code__c From Lead Where Customer_Code__c IN :OppotunityCustId])
   {
    matchingLeadMap.put(Ld.Status, Ld);
   }
   
   List <Opportunity> opportunityToUpdate = new List <Opportunity> ();
   
   for(Opportunity Opp : trigger.New)
{
    if (matchingLeadMap.get(Opp.Customer_ID__c) != null)
    {
        // we found a mathing one
        Opp.Lead_Exception__c = matchingLeadMap.get(Opp.Lead_Exception__c).Id;

        // add it to a separate list and update it
        opportunityToUpdate.add(Opp);
    }

update OpportunityToUpdate;
}

but that Status form lead is not coping in opportunity lead exception field.Please help.
Hi,

account obj is parent of Lead and opportunity.I want to copy Lead status from lead obj to opportunity obj with matching of account id.Please help.
Hi,

I want to copy one value from child obj to parent obj.

trigger Copyleadvaluetoacc on Lead (after insert, after update) {
    
    List<Id> accIds = new List<Id>();
    List<Account> accounts = new List<Account>();
    
    for(Lead L : trigger.new){
        accIds.add(L.Id);
    }
    
    for(Account a : [SELECT Id, Lead_Status__c FROM Account WHERE Id IN :accIds]){
        for(Lead ld:  trigger.new){
            a.Lead_Status__c=ld.Status;
            accounts.add(a);
        }
    }
    if(accounts.size()>0){
        Update accounts;
    }

But it is not working.Please help
HI,

I am having a text field.I wnat a length validation on that.

AND(ISPICKVAL(Vertical__c,'HI'),NOT(LEN(Proposal_Application_Number__c)=10))

but it is not working.Field should only accept 10 digit numeric number for HI vertical.
HI,

I am having one picklist field in lead object.Values are Open,Accept,Working,Converted.Based on this fields value I am capturing dates also.Now I want to create one formula field which will show me how many days this leads are having in which status.Means How many days it is in Open Status,in Accept status.

if(ISPICKVAL(Status, 'Accept') , DATETIMEVALUE( Date_of_Staring_Working__c) - DATETIMEVALUE( Date_of_Acceptance__c),DATETIMEVALUE( TODAY()) - DATETIMEVALUE( Date_of_Acceptance__c))

I have written this but it is not working.I will create different formula fields for capturing the days.Please help.
Hi,

I have written one class and onee trigeer for sendinf sms.but it is not working.Please help.

Class : 

public class SMSTask {

 public string strMobNo{ get; set; }
    
    public SMSTask(ApexPages.StandardController controller){
        String MBRid;
    }
        
    public SMSTask () { }
    
    Public void sendMessage(){
        Http http  = new Http(); 
        HttpRequest req = new HttpRequest(); 
        String fromNum='918973147939';
        //String toNum= '919790882125';
        strMobNo = '919790882125';
        req.setEndpoint('http://www.myvaluefirst.com/smpp/sendsms?username=dempeerlesshttp&password=demo4321&to=91'+strMobNo+'&from='+fromNum+'&text=hi'); 
        req.setMethod('GET');
        if (test.isRunningTest()!=true) HttpResponse res = http.send(req); 
        //XMLDom responseXML = new XMLDom(res.getBody());   
    }
    
    @future (callout=true)
    Public static void smsCustomer1(Id tskId) {
        SMS_Settings__c smsS = [select id, Name, senderId__c,task_sms__c,Mobile_Number__c, ValueFirst_Username__c, ValueFirst_Password__c from SMS_Settings__c where name ='Proposal2'] ; 
        Task tsk = [select id,Status,Proposal_Number__r.Account_Name__r.FirstName,Proposal_Number__r.Account_Name__r.LastName,Proposal_Number__r.Account_Name__r.PersonMobilePhone 
                    from Task where id=:tskId];
                                            
        String fromNo = smsS.senderId__c; //'PGFIIT';
        String toNo =  '91' + tsk.Proposal_Number__r.Account_Name__r.PersonMobilePhone; // '919790882125'; // 
        String Name = tsk.Proposal_Number__r.Account_Name__r.FirstName + ' '+ tsk.Proposal_Number__r.Account_Name__r.LastName; 
        //system.debug(Name + '\n'+ppd.Paid_Amount__c+'\n'+ppd.Premium__r.Proposal_Number__c);
        String message = smss.task_sms__c.replace('CUSTNAME', Name);
        //message = message.replace('PAYAMOUNT', String.valueOf(ppd.Paid_Amount__c));
        //message = message.replace('PROPID', ppd.Premium__r.Proposal_Number__c); 
        String xmlMessage = '<?xml version="1.0" encoding="ISO-8859-1"?>';
                xmlMessage += '<!DOCTYPE MESSAGE SYSTEM "http://127.0.0.1/psms/dtd/message.dtd" >';
                xmlMessage += '<MESSAGE><USER USERNAME="'+smss.ValueFirst_Username__c+'" PASSWORD="'+smss.ValueFirst_Password__c+'"/>';
                xmlMessage += '<SMS UDH="0" CODING="1" TEXT="'+message +'" PROPERTY="0" ID="'+tskId+'">';
                xmlMessage += '<ADDRESS FROM="'+ fromNo +'" TO="'+toNo +'" SEQ="1" TAG="Premium Payment" />';
                xmlMessage += '</SMS></MESSAGE>';
        String encodedUrl = 'http://api.myvaluefirst.com/psms/servlet/psms.Eservice2?action=send&data='+EncodingUtil.urlEncode(xmlMessage, 'UTF-8');
        String decodedUrl = EncodingUtil.urlDecode(encodedUrl, 'UTF-8');  system.debug(decodedUrl);
        Http h = new Http(); 
        HttpRequest req = new HttpRequest(); 
        req.setEndpoint(encodedUrl); 
        req.setMethod('GET');
        if (test.isRunningTest()!=true) {
            HttpResponse res = invokeWebService(h, req); handleWebServiceResponseCust(tskId);
            system.debug(res.getBody());
        } else {
            handleWebServiceResponseCust(tskId);
        }
    }
    
    public static HttpResponse invokeWebService(Http h, HttpRequest req){
        HttpResponse res = h.send(req); return res;
    }

  public static void handleWebServiceResponseCust(String tskid){
        Task tsk = [select id,Status,task_sms__c,Proposal_Number__r.Account_Name__r.PersonMobilePhone from Task where id=:tskId];
        if (tsk.Status == 'Completed') {
            tsk.task_sms__c = true;
            update tsk;
        }
    }



}



Trigger :

trigger SendSMS_Task on Task (after update) {
    
   
   if(trigger.oldmap != trigger.newmap)
   {
    map<Id, Task> mapPD = new map<Id, Task>();
    set<Id> setPId = new set<Id>();
    set<Id> setTK_cust = new set<Id>();
    
    
    
    for (Task tskRow: [select id,Status,task_sms__c,Proposal_Number__r.Account_Name__r.PersonMobilePhone from Task
                                             where Status = 'Completed']){
        system.debug(' Task ->  '+ tskRow);
        for (Task tkRow: trigger.new) {
            
                if(trigger.oldMap.get(tkRow.id).Status == 'Completed' && tskRow.task_sms__c == false) { 
                    setTK_cust.add(tskRow.id);
                }
                
        }
    }
    
    for (String cid: setTK_cust ) {  SMSTask.smsCustomer1(cid);
    }
    
    }

}

Please help
Hello,

How to cover this portion.Please help with sample code.

@future (callout=true)
    Public static void smsCustomer1(Id tskId) {
        SMS_Settings__c smsS = [select id, Name, senderId__c,task_sms__c,Mobile_Number__c, ValueFirst_Username__c, ValueFirst_Password__c from SMS_Settings__c where name ='Proposal'] ; 
        Task tsk = [select id,Status,Proposal_Number__r.Account_Name__r.FirstName,Proposal_Number__r.Account_Name__r.LastName,Proposal_Number__r.Account_Name__r.PersonMobilePhone 
                    from Task where id=:tskId];
                                            
        String fromNo = smsS.senderId__c; //'PGFIIT';
        String toNo =  '91' + tsk.Proposal_Number__r.Account_Name__r.PersonMobilePhone; // '919790882125'; // 
        String Name = tsk.Proposal_Number__r.Account_Name__r.FirstName + ' '+ tsk.Proposal_Number__r.Account_Name__r.LastName; 
        String message = smss.task_sms__c.replace('CUSTNAME', Name);
        String xmlMessage = '<?xml version="1.0" encoding="ISO-8859-1"?>';
                xmlMessage += '<!DOCTYPE MESSAGE SYSTEM "http://127.0.0.1/psms/dtd/message.dtd" >';
                xmlMessage += '<MESSAGE><USER USERNAME="'+smss.ValueFirst_Username__c+'" PASSWORD="'+smss.ValueFirst_Password__c+'"/>';
                xmlMessage += '<SMS UDH="0" CODING="1" TEXT="'+message +'" PROPERTY="0" ID="'+tskId+'">';
                xmlMessage += '<ADDRESS FROM="'+ fromNo +'" TO="'+toNo +'" SEQ="1" TAG="Premium Payment" />';
                xmlMessage += '</SMS></MESSAGE>';
        String encodedUrl = 'http://api.myvaluefirst.com/psms/servlet/psms.Eservice2?action=send&data='+EncodingUtil.urlEncode(xmlMessage, 'UTF-8');
        String decodedUrl = EncodingUtil.urlDecode(encodedUrl, 'UTF-8');  system.debug(decodedUrl);
        Http h = new Http(); 
        HttpRequest req = new HttpRequest(); 
        req.setEndpoint(encodedUrl); 
        req.setMethod('GET');
        if (test.isRunningTest()!=true) {
            HttpResponse res = invokeWebService(h, req); handleWebServiceResponseCust(tskId);
            system.debug(res.getBody());
        } else {
            handleWebServiceResponseCust(tskId);
        }
Hi,

Can anyone help me with code coverage.

Class:

public class SMSTask {

 public string strMobNo{ get; set; }
    
    public SMSTask(ApexPages.StandardController controller){
        String MBRid;
    }
        
    public SMSTask () { }
    
    Public void sendMessage(){
        Http http  = new Http(); 
        HttpRequest req = new HttpRequest(); 
        String fromNum='918973147939';
        //String toNum= '919790882125';
        strMobNo = '919790882125';
        req.setEndpoint('http://www.myvaluefirst.com/smpp/sendsms?username=dempeerlesshttp&password=demo4321&to=91'+strMobNo+'&from='+fromNum+'&text=hi'); 
        req.setMethod('GET');
        if (test.isRunningTest()!=true) HttpResponse res = http.send(req); 
        //XMLDom responseXML = new XMLDom(res.getBody());   
    }
    
    @future (callout=true)
    Public static void smsCustomer1(Id tskId) {
        SMS_Settings__c smsS = [select id, Name, senderId__c,task_sms__c,Mobile_Number__c, ValueFirst_Username__c, ValueFirst_Password__c from SMS_Settings__c where name ='Proposal'] ; 
        Task tsk = [select id,Status,Proposal_Number__r.Account_Name__r.FirstName,Proposal_Number__r.Account_Name__r.LastName,Proposal_Number__r.Account_Name__r.PersonMobilePhone 
                    from Task where id=:tskId];
                                            
        String fromNo = smsS.senderId__c; //'PGFIIT';
        String toNo =  '91' + tsk.Proposal_Number__r.Account_Name__r.PersonMobilePhone; // '919790882125'; // 
        String Name = tsk.Proposal_Number__r.Account_Name__r.FirstName + ' '+ tsk.Proposal_Number__r.Account_Name__r.LastName; 
        //system.debug(Name + '\n'+ppd.Paid_Amount__c+'\n'+ppd.Premium__r.Proposal_Number__c);
        String message = smss.task_sms__c.replace('CUSTNAME', Name);
        //message = message.replace('PAYAMOUNT', String.valueOf(ppd.Paid_Amount__c));
        //message = message.replace('PROPID', ppd.Premium__r.Proposal_Number__c); 
        String xmlMessage = '<?xml version="1.0" encoding="ISO-8859-1"?>';
                xmlMessage += '<!DOCTYPE MESSAGE SYSTEM "http://127.0.0.1/psms/dtd/message.dtd" >';
                xmlMessage += '<MESSAGE><USER USERNAME="'+smss.ValueFirst_Username__c+'" PASSWORD="'+smss.ValueFirst_Password__c+'"/>';
                xmlMessage += '<SMS UDH="0" CODING="1" TEXT="'+message +'" PROPERTY="0" ID="'+tskId+'">';
                xmlMessage += '<ADDRESS FROM="'+ fromNo +'" TO="'+toNo +'" SEQ="1" TAG="Premium Payment" />';
                xmlMessage += '</SMS></MESSAGE>';
        String encodedUrl = 'http://api.myvaluefirst.com/psms/servlet/psms.Eservice2?action=send&data='+EncodingUtil.urlEncode(xmlMessage, 'UTF-8');
        String decodedUrl = EncodingUtil.urlDecode(encodedUrl, 'UTF-8');  system.debug(decodedUrl);
        Http h = new Http(); 
        HttpRequest req = new HttpRequest(); 
        req.setEndpoint(encodedUrl); 
        req.setMethod('GET');
        if (test.isRunningTest()!=true) {
            HttpResponse res = invokeWebService(h, req); handleWebServiceResponseCust(tskId);
            system.debug(res.getBody());
        } else {
            handleWebServiceResponseCust(tskId);
        }
    }
    
    public static HttpResponse invokeWebService(Http h, HttpRequest req){
        HttpResponse res = h.send(req); return res;
    }

  public static void handleWebServiceResponseCust(String tskid){
        Task tsk = [select id,Status,task_sms__c,Proposal_Number__r.Account_Name__r.PersonMobilePhone from Task where id=:tskId];
        if (tsk.Status == 'Completed') {
            tsk.task_sms__c = true;
            update tsk;
        }
    }



}

Test Class :

@isTest (SeeAllData=true)
private class TestTaskSMS{
    static testMethod void testTaskSMS() {
        test.startTest();
        RecordType rt = [select id from RecordType where sObjectType = 'Account' and Name = 'Individual'];
        Account a = new Account(Salutation = 'Mr', FirstName='Test', LastName='Test Acc', PersonMobilePhone='9790882125', RecordTypeId = rt.Id, House_No_Street__c = 'Address');
        insert a;
        Proposal_Details__c propd = new Proposal_Details__c( Account_Name__c = a.Id, Status_del__c = 'Initiated', Proposal_Application_Number__c = '001' );
        insert propd;
        SMS_Details__c SMS = new SMS_Details__c(Message__c = 'Test1', Mobile_Number__c = '9791222241', GUID__c = 'kgckh225103451f410014fveqh--PFPDLXML', Submited_Date_Time__c = Date.Today());
        insert SMS;
        
        SMS_Details__c SMS1 = new SMS_Details__c(Message__c = 'Test1', Mobile_Number__c = '9791222241', GUID__c = 'kgckh225103451f410014fveqh--PFPDLXML', 
        SMS_Request_Sent__c = TRUE, Submited_Date_Time__c = Date.Today());
        insert SMS1;
        
        SMS_Settings__c st = new SMS_Settings__c(Name='Proposal1', SenderId__c = 'PGFIIT', ValueFirst_Username__c = 'pfpdlxml', ValueFirst_Password__c = 'pfpxml@123');
        insert st;
        Task tsk=new Task(Status = 'Planned');
        insert tsk;
        tsk.Status = 'Completed';
        update tsk;
        
       
        SMSTask si = new SMSTask();
        si.sendMessage();
        
        OI_custom_SMS_Settings sms5 = new OI_custom_SMS_Settings ();
        sms5.getsmss();
        sms5.save();
        
        test.stopTest();
    }
}

Please help
Hi,

I am having some lead data uploaded in lead management.All the leads are assigned to separate branch queue.I want when a user logged in and modify one lead that lead must be assinged to that particular logged in user.If possible based on one pick list value.Like Lead_Status__c = "Accept".

Please help.
Hi,

I am using Lead object for salesforce mobile app through lightning app builder.But I am unble to use lead object Accept and convert button.Please let me know how to use it in lightning app.I have added this to quick action but it is not working in salesforce mobile app.Please help.
Hi,
I am one onclick javascript button in a custom object.

{!requireScript("/soap/ajax/26.0/connection.js")}
var deno = new sforce.SObject("Denomination__c");

deno.id = "{!Denomination__c.Id}";
var cDate="{!Denomination__c.CreatedDate}";
var name= "{!Denomination__c.Name}";
var isTransfered= "{!Denomination__c.Transfer__c}";
var isApproved = "{!Denomination__c.Approve__c}";
var message = confirm('Are you sure you want to continue? Click OK to continue.');
if(message)
{
if((isTransfered == 'true' || isTransfered == 1) && isApproved =='Yes')
{
alert('Denomination is already Authorized.')
}
else
{
//Assign the values

deno.Transfer__c= true;
//alert(deno.Transfer__c);
deno.Approve__c= "Yes";
//alert(deno.Approve__c);
//Random No Generation with Created date
var randNo=Math.floor((Math.random() * 100000) + 1);
var abmSeqNo= name+'-'+randNo;
randNo+'/'+cDate+'/'+name;
name+'/'+randNo;

if(abmSeqNo){
deno.ABM_Sequence_No__c= name.replace('E','A');
}
var r=sforce.connection.update([deno]);
window.location.reload(); //to reload the window and show the updated values
}
}

So can anyone guide me how to convert it with Lightning components and controller class.

Thanks in Advance
Hi ,
I am having a formula field.I want to remove some condition but I am unable to do that.
IF(ISPICKVAL(Vertical__c,'LI'), 
IF(NOT(ISPICKVAL(ProductDetail__r.Pricing_Category__c,'ULIP')), 
((NULLVALUE(Base_Premium__c,0)+NULLVALUE(Rider_Premium__c,0))+ 
IF((Inception_Branch__c != '641'), 
IF((Principle_Code__c = 'MLI'), 
IF(Year_of_Policy__c=1, 
(NULLVALUE(Base_Premium__c,0)*0.045 )+(Rider_Premium__c*0.1800), 
(NULLVALUE(Base_Premium__c,0)*0.0225 )+(Rider_Premium__c*0.18)), 
IF(AND(ProductDetail__r.Scheme_Code__c!='BPP1',ProductDetail__r.Scheme_Code__c != 'BPP2'), 
NULLVALUE(Base_Premium__c,0)*0.045, 
NULLVALUE(Base_Premium__c,0)*0.1800)+(Rider_Premium__c*0.1800)), 
IF((Principle_Code__c='BSLI'), 
IF(AND(ProductDetail__r.Scheme_Code__c!='BPP1',ProductDetail__r.Scheme_Code__c!='BPP2'), 
NULLVALUE(Base_Premium__c,0)*0.045, 
NULLVALUE(Base_Premium__c,0)*0),0))),NULLVALUE(Base_Premium__c,0)), 

IF(ISPICKVAL(Vertical__c,'GI'), 
IF(AND(ISPICKVAL(ProductDetail__r.Pricing_Category__c ,'Motor'),ProductDetail__r.CommercialValue_Flag__c= False), 
(NULLVALUE(Own_Damage_Premium__c,0)+NULLVALUE(Third_Party_Premium__c,0) ) * (1.1800), 

IF(AND(ISPICKVAL(ProductDetail__r.Pricing_Category__c ,'Motor'),ProductDetail__r.CommercialValue_Flag__c= True ), 
(NULLVALUE(Own_Damage_Premium__c,0)+NULLVALUE(Third_Party_Premium__c,0) ) + NULLVALUE(Own_Damage_Premium__c,0) *0.18 + NULLVALUE(Third_Party_Premium__c,0) * 0.12 , 

IF(ISPICKVAL(ProductDetail__r.Pricing_Category__c,'Non-Motor'), 
(NULLVALUE(Base_Premium__c,0)+NULLVALUE(Terrorism_Premium__c,0)) * ( 1.1800) , 
NULLVALUE(Base_Premium__c,0)))), 

IF(ISPICKVAL(Vertical__c,'MF'), 
NULLVALUE(MF_Amount__c,0), 

IF(or(ISPICKVAL(Vertical__c,'HI'),ISPICKVAL(Vertical__c,'HC')), 
NULLVALUE(Base_Premium__c,0)*(1.1800),0))))

In the above mentioned formula I want to remove below mentioned portion.

IF(AND(ProductDetail__r.Scheme_Code__c!='BPP1',ProductDetail__r.Scheme_Code__c != 'BPP2'), 
NULLVALUE(Base_Premium__c,0)*0.045, 
NULLVALUE(Base_Premium__c,0)*0.1800)+(Rider_Premium__c*0.1800)), 
IF((Principle_Code__c='BSLI'), 
IF(AND(ProductDetail__r.Scheme_Code__c!='BPP1',ProductDetail__r.Scheme_Code__c!='BPP2'), 
NULLVALUE(Base_Premium__c,0)*0.045, 
NULLVALUE(Base_Premium__c,0)*0),0))),

But I am getting error.Please help.
Hi,
public PageReference pageChange ()
    { 
        string vertical = ApexPages.currentPage().getParameters().get('vert');string PrinCode = ApexPages.currentPage().getParameters().get('PriCd');string ArnNo = ApexPages.currentPage().getParameters().get('Arn');
        string isrollover = ApexPages.currentPage().getParameters().get('Rollover');

I want to change String to boolean,but when I am giving it as Boolean isrollover = ......

It is showing error.Please help.
Hi,

I am using one trigger which will calculate a date range from my Policy object to Opportunity Object.
I am having a field named Proposal Date in Opportunity and Maturity date in policy object.
So I want to put a logic like if proposal date is 12/3/2019 so the Maturity date should be 19/3/2019 to 30/3/2019.If this range will true then it will okay otherwise it will through a error.
I have written something like 
 if(io1.Proposal_Date__c<po.Maturity_Date__c-7)
but this is not working.Please help.
Hi,

I am using Salesforce Mobile app.In salesforce mobile app when I am searching my lead in lookup only Lead name is appearing.I want to see some more filed in Mobile lookup search like name,mobile no,Address.Please help.
Hi,

I want to updateto date field based on another object value.If my Case object having a picklist field value ABCD then in policy object i wnat to update two date fields.I will match Policy no from my case object so that it will update that exact policy start date and end date. Please help
Hi,

I have written one trigger.

trigger CopyleadvaluetoOpp on Opportunity (after insert) {
   
   Set <String> OppotunityCustId = new Set <String> ();
   
   for(Opportunity Opp : trigger.New)
   {
    OppotunityCustId.add(Opp.Customer_ID__c);
   }

   Map <String, Lead> matchingLeadMap = new Map <String, Lead> ();
   
   for (Lead Ld : [Select Id,Status,Customer_Code__c From Lead Where Customer_Code__c IN :OppotunityCustId])
   {
    matchingLeadMap.put(Ld.Status, Ld);
   }
   
   List <Opportunity> opportunityToUpdate = new List <Opportunity> ();
   
   for(Opportunity Opp : trigger.New)
{
    if (matchingLeadMap.get(Opp.Customer_ID__c) != null)
    {
        // we found a mathing one
        Opp.Lead_Exception__c = matchingLeadMap.get(Opp.Lead_Exception__c).Id;

        // add it to a separate list and update it
        opportunityToUpdate.add(Opp);
    }

update OpportunityToUpdate;
}

but that Status form lead is not coping in opportunity lead exception field.Please help.
Hi,

account obj is parent of Lead and opportunity.I want to copy Lead status from lead obj to opportunity obj with matching of account id.Please help.
Hi,

I want to copy one value from child obj to parent obj.

trigger Copyleadvaluetoacc on Lead (after insert, after update) {
    
    List<Id> accIds = new List<Id>();
    List<Account> accounts = new List<Account>();
    
    for(Lead L : trigger.new){
        accIds.add(L.Id);
    }
    
    for(Account a : [SELECT Id, Lead_Status__c FROM Account WHERE Id IN :accIds]){
        for(Lead ld:  trigger.new){
            a.Lead_Status__c=ld.Status;
            accounts.add(a);
        }
    }
    if(accounts.size()>0){
        Update accounts;
    }

But it is not working.Please help
Hello,

How to cover this portion.Please help with sample code.

@future (callout=true)
    Public static void smsCustomer1(Id tskId) {
        SMS_Settings__c smsS = [select id, Name, senderId__c,task_sms__c,Mobile_Number__c, ValueFirst_Username__c, ValueFirst_Password__c from SMS_Settings__c where name ='Proposal'] ; 
        Task tsk = [select id,Status,Proposal_Number__r.Account_Name__r.FirstName,Proposal_Number__r.Account_Name__r.LastName,Proposal_Number__r.Account_Name__r.PersonMobilePhone 
                    from Task where id=:tskId];
                                            
        String fromNo = smsS.senderId__c; //'PGFIIT';
        String toNo =  '91' + tsk.Proposal_Number__r.Account_Name__r.PersonMobilePhone; // '919790882125'; // 
        String Name = tsk.Proposal_Number__r.Account_Name__r.FirstName + ' '+ tsk.Proposal_Number__r.Account_Name__r.LastName; 
        String message = smss.task_sms__c.replace('CUSTNAME', Name);
        String xmlMessage = '<?xml version="1.0" encoding="ISO-8859-1"?>';
                xmlMessage += '<!DOCTYPE MESSAGE SYSTEM "http://127.0.0.1/psms/dtd/message.dtd" >';
                xmlMessage += '<MESSAGE><USER USERNAME="'+smss.ValueFirst_Username__c+'" PASSWORD="'+smss.ValueFirst_Password__c+'"/>';
                xmlMessage += '<SMS UDH="0" CODING="1" TEXT="'+message +'" PROPERTY="0" ID="'+tskId+'">';
                xmlMessage += '<ADDRESS FROM="'+ fromNo +'" TO="'+toNo +'" SEQ="1" TAG="Premium Payment" />';
                xmlMessage += '</SMS></MESSAGE>';
        String encodedUrl = 'http://api.myvaluefirst.com/psms/servlet/psms.Eservice2?action=send&data='+EncodingUtil.urlEncode(xmlMessage, 'UTF-8');
        String decodedUrl = EncodingUtil.urlDecode(encodedUrl, 'UTF-8');  system.debug(decodedUrl);
        Http h = new Http(); 
        HttpRequest req = new HttpRequest(); 
        req.setEndpoint(encodedUrl); 
        req.setMethod('GET');
        if (test.isRunningTest()!=true) {
            HttpResponse res = invokeWebService(h, req); handleWebServiceResponseCust(tskId);
            system.debug(res.getBody());
        } else {
            handleWebServiceResponseCust(tskId);
        }
Hi,

Can anyone help me with code coverage.

Class:

public class SMSTask {

 public string strMobNo{ get; set; }
    
    public SMSTask(ApexPages.StandardController controller){
        String MBRid;
    }
        
    public SMSTask () { }
    
    Public void sendMessage(){
        Http http  = new Http(); 
        HttpRequest req = new HttpRequest(); 
        String fromNum='918973147939';
        //String toNum= '919790882125';
        strMobNo = '919790882125';
        req.setEndpoint('http://www.myvaluefirst.com/smpp/sendsms?username=dempeerlesshttp&password=demo4321&to=91'+strMobNo+'&from='+fromNum+'&text=hi'); 
        req.setMethod('GET');
        if (test.isRunningTest()!=true) HttpResponse res = http.send(req); 
        //XMLDom responseXML = new XMLDom(res.getBody());   
    }
    
    @future (callout=true)
    Public static void smsCustomer1(Id tskId) {
        SMS_Settings__c smsS = [select id, Name, senderId__c,task_sms__c,Mobile_Number__c, ValueFirst_Username__c, ValueFirst_Password__c from SMS_Settings__c where name ='Proposal'] ; 
        Task tsk = [select id,Status,Proposal_Number__r.Account_Name__r.FirstName,Proposal_Number__r.Account_Name__r.LastName,Proposal_Number__r.Account_Name__r.PersonMobilePhone 
                    from Task where id=:tskId];
                                            
        String fromNo = smsS.senderId__c; //'PGFIIT';
        String toNo =  '91' + tsk.Proposal_Number__r.Account_Name__r.PersonMobilePhone; // '919790882125'; // 
        String Name = tsk.Proposal_Number__r.Account_Name__r.FirstName + ' '+ tsk.Proposal_Number__r.Account_Name__r.LastName; 
        //system.debug(Name + '\n'+ppd.Paid_Amount__c+'\n'+ppd.Premium__r.Proposal_Number__c);
        String message = smss.task_sms__c.replace('CUSTNAME', Name);
        //message = message.replace('PAYAMOUNT', String.valueOf(ppd.Paid_Amount__c));
        //message = message.replace('PROPID', ppd.Premium__r.Proposal_Number__c); 
        String xmlMessage = '<?xml version="1.0" encoding="ISO-8859-1"?>';
                xmlMessage += '<!DOCTYPE MESSAGE SYSTEM "http://127.0.0.1/psms/dtd/message.dtd" >';
                xmlMessage += '<MESSAGE><USER USERNAME="'+smss.ValueFirst_Username__c+'" PASSWORD="'+smss.ValueFirst_Password__c+'"/>';
                xmlMessage += '<SMS UDH="0" CODING="1" TEXT="'+message +'" PROPERTY="0" ID="'+tskId+'">';
                xmlMessage += '<ADDRESS FROM="'+ fromNo +'" TO="'+toNo +'" SEQ="1" TAG="Premium Payment" />';
                xmlMessage += '</SMS></MESSAGE>';
        String encodedUrl = 'http://api.myvaluefirst.com/psms/servlet/psms.Eservice2?action=send&data='+EncodingUtil.urlEncode(xmlMessage, 'UTF-8');
        String decodedUrl = EncodingUtil.urlDecode(encodedUrl, 'UTF-8');  system.debug(decodedUrl);
        Http h = new Http(); 
        HttpRequest req = new HttpRequest(); 
        req.setEndpoint(encodedUrl); 
        req.setMethod('GET');
        if (test.isRunningTest()!=true) {
            HttpResponse res = invokeWebService(h, req); handleWebServiceResponseCust(tskId);
            system.debug(res.getBody());
        } else {
            handleWebServiceResponseCust(tskId);
        }
    }
    
    public static HttpResponse invokeWebService(Http h, HttpRequest req){
        HttpResponse res = h.send(req); return res;
    }

  public static void handleWebServiceResponseCust(String tskid){
        Task tsk = [select id,Status,task_sms__c,Proposal_Number__r.Account_Name__r.PersonMobilePhone from Task where id=:tskId];
        if (tsk.Status == 'Completed') {
            tsk.task_sms__c = true;
            update tsk;
        }
    }



}

Test Class :

@isTest (SeeAllData=true)
private class TestTaskSMS{
    static testMethod void testTaskSMS() {
        test.startTest();
        RecordType rt = [select id from RecordType where sObjectType = 'Account' and Name = 'Individual'];
        Account a = new Account(Salutation = 'Mr', FirstName='Test', LastName='Test Acc', PersonMobilePhone='9790882125', RecordTypeId = rt.Id, House_No_Street__c = 'Address');
        insert a;
        Proposal_Details__c propd = new Proposal_Details__c( Account_Name__c = a.Id, Status_del__c = 'Initiated', Proposal_Application_Number__c = '001' );
        insert propd;
        SMS_Details__c SMS = new SMS_Details__c(Message__c = 'Test1', Mobile_Number__c = '9791222241', GUID__c = 'kgckh225103451f410014fveqh--PFPDLXML', Submited_Date_Time__c = Date.Today());
        insert SMS;
        
        SMS_Details__c SMS1 = new SMS_Details__c(Message__c = 'Test1', Mobile_Number__c = '9791222241', GUID__c = 'kgckh225103451f410014fveqh--PFPDLXML', 
        SMS_Request_Sent__c = TRUE, Submited_Date_Time__c = Date.Today());
        insert SMS1;
        
        SMS_Settings__c st = new SMS_Settings__c(Name='Proposal1', SenderId__c = 'PGFIIT', ValueFirst_Username__c = 'pfpdlxml', ValueFirst_Password__c = 'pfpxml@123');
        insert st;
        Task tsk=new Task(Status = 'Planned');
        insert tsk;
        tsk.Status = 'Completed';
        update tsk;
        
       
        SMSTask si = new SMSTask();
        si.sendMessage();
        
        OI_custom_SMS_Settings sms5 = new OI_custom_SMS_Settings ();
        sms5.getsmss();
        sms5.save();
        
        test.stopTest();
    }
}

Please help
Hi,

I am using Salesforce Mobile app.In salesforce mobile app when I am searching my lead in lookup only Lead name is appearing.I want to see some more filed in Mobile lookup search like name,mobile no,Address.Please help.
Hi,

I want to updateto date field based on another object value.If my Case object having a picklist field value ABCD then in policy object i wnat to update two date fields.I will match Policy no from my case object so that it will update that exact policy start date and end date. Please help