• Priya Mishra
  • NEWBIE
  • 60 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 40
    Questions
  • 38
    Replies
Hi All,

I have a requriement where in the Dashboard Page i want to have a Picklist and Based on the Value selected from the Picklist (Piclist values : country, Task) the dashboard data should display.

can we acheive this using configutaion or we have to go for customization if customization how we can achieve this pls help me on this reuirement.

Thanks.
Hi All,Pls help me to cover the below class.

public with sharing class ESignRedirectionController_MDSR
{

    private String anchor {get;set;}
    public String state {get;set;}
    public Boolean response {get;set;}
    public PageReference recordURL {get;set;}
    public string isError {get;set;}
    public String res {get;set;}
    public String InvoiceSelectedVal {get;set;}
    public Boolean isInvoiceAuto {get;set;}
    
    public final static String endPoint = URL.getSalesforceBaseUrl().toExternalForm().toLowerCase();
    public final static String redirectUri = '/apex/EsignRedirection_MDSR';
    
    private final static String Incorrect_Authentication = 'Incorrect_Authentication';
    
    public String getIncorrectAuthentication()
    {
        return Incorrect_Authentication;
    }
    
    public MedConnect__Work_Order_Action__c woAction {get;set;}
    public MedConnect__Work_Order__c workOrder {get;set;}
    
    private ESignRedirectionController_MDSR(Boolean dummy)
    {
    }
    public void processAnchor()
    {
        response = false;
        state = ApexPages.currentPage().getParameters().get('state');
        anchor = ApexPages.currentPage().getAnchor();
        Map<String, String> parametersMap;
        if(anchor != null)
            parametersMap = getParametersFromAnchor(anchor);
        if(state != null && anchor != null && verifyAccessToken(parametersMap.get('access_token')))
            response = true;
        if(response)
        {
            woAction = new MedConnect__Work_Order_Action__c(MedConnect__Work_Order__c = state);
            recordURL = new PageReference ('/' + state);
        
            workOrder = [SELECT Id, Name FROM MedConnect__Work_Order__c Where Id = :state];
        }
    }
    public ESignRedirectionController_MDSR()
    {
        processAnchor();
    }
    
    public String integrationStatus {get;set;}
    //public PageReference save()
    public void save()
    {
        /*****************************************************************************************
        Below piece of code has been added to check the Work Order's Eligibility to be sent to
        ERP systems and set the Work Order as well as associated Repair Installation History Lines 
        Integration Status & Description accordingly - Anjali
        ******************************************************************************************/
        Final list<Id> woId = new list<Id>();//Integration Code start
        woId.add(workOrder.Id);
        String retString = SetWOIntegrationStatusHandler_MDSR.getWODetails(woId);
        boolean checkretString = (retString != null && !string.isblank(retString));
        //AHLF-1794
        if(this.InvoiceSelectedVal == null || String.isBlank(this.InvoiceSelectedVal)){
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, 'Please select either of the Invoice creation options prior to submitting'));
            return;
        }
        // end of AHLF-1794
        if(checkretString){
            //integrationStatus = retString;
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.WARNING, retString));
            integrationStatus = retString;
        }
        else
        {
            integrationStatus = '';
        }//Integration Code End
        /* Added by sdhali for R5.3 UAT Defect Fix Start */
        list<MedConnect__Work_Order__c> wolistEliUpdate= new list<MedConnect__Work_Order__c>();
      list<MedConnect__Work_Order__c> wolistNEliUpdate= new list<MedConnect__Work_Order__c>();
        list<MedConnect__Work_Order__c> wolistNElifrmEliUpdate= new list<MedConnect__Work_Order__c>();
        
        wolistEliUpdate = SetWOIntegrationStatusHandlerUtil_MDSR.wolistEli;
        wolistNEliUpdate =SetWOIntegrationStatusHandlerUtil_MDSR.wolistNonEli;
        wolistNElifrmEliUpdate =SetWOIntegrationStatusHandlerUtil_MDSR.wolistNonEliFromEli;
        boolean checkwolistEliUpdate =(!wolistEliUpdate.isEmpty());
        boolean checkwolistNEliUpdate = (!wolistNEliUpdate.isEmpty());
        boolean checkwolistNElifrmEliUpdate = (!wolistNElifrmEliUpdate.isEmpty());
        if(checkwolistEliUpdate)
        {  
            workOrder.ERP_Name_MDSR__c = SetWOIntegrationStatusHandlerUtil_MDSR.erpNameFinal;
            workOrder.Integration_Status_ERP_MDSR__c = SetWOIntegrationStatusHandler_MDSR.inProcessStatus;
            workOrder.Integration_Description_ERP_MDSR__c = '';
            workOrder.Middleware_Name_MDSR__c = SetWOIntegrationStatusHandlerUtil_MDSR.mwareName;
        }
        else if(checkwolistNEliUpdate)
        {  
            workOrder.Integration_Status_ERP_MDSR__c = SetWOIntegrationStatusHandler_MDSR.integStatusNA;
            workOrder.Integration_Description_ERP_MDSR__c = '';
        }
        else if(checkwolistNElifrmEliUpdate)
        {
            workOrder.Integration_Status_ERP_MDSR__c = SetWOIntegrationStatusHandler_MDSR.integStatusNA;//Set WO integration status as NA
            workOrder.Integration_Description_ERP_MDSR__c = '';//Anjali added no 17/10/17
            workOrder.ERP_Name_MDSR__c = '';//Check if this is needed.
        }
        //AHLF-1794
        if(this.InvoiceSelectedVal == 'True'){
            this.isInvoiceAuto = true;
        }
         if(this.InvoiceSelectedVal == 'False'){
            this.isInvoiceAuto = false;
        }
        //changes of AHLF-1794
        /* Added for R5.3 UAT Defect Fix End */
        workOrder.MedConnect__Processing_Status__c = 'Completed';
        workOrder.MedConnect__Reason_For_Change__c = 'Approved';
        workOrder.Auto_Create_Invoice_MDSR__c = this.isInvoiceAuto; // AHLF-1794
        update workOrder;
        
        List<MedConnect__Work_Order_Action__c> woaList = [SELECT Id, CreatedDate,Signature_Meaning_MDSR__c FROM 
            MedConnect__Work_Order_Action__c WHERE MedConnect__Work_Order__c = 
            :workOrder.Id ORDER BY CreatedDate DESC LIMIT 1];
        if(!woaList.isEmpty())
        {
            woAction.MedConnect__Previous_Action_Date__c = woaList[0].CreatedDate;
        }
        woAction.MedConnect__Action_Label__c = 'Completed';
        woAction.MedConnect__Action_Name__c = 'Completed';
        woAction.MedConnect__Performed_By__c = UserInfo.getUserId();        
        woAction.MedConnect__Work_Order__c = workOrder.Id;
        woAction.Electronically_Signed__c = true;
        woAction.Signature_Comment_MDSR__c = woAction.Signature_Meaning_MDSR__c;
        try
        {
        isError = 'false'; 
        insert woAction;
        }
        catch(exception e)
        {
          isError = 'true'; 
        }
        /*****************************************************************************************
        Below piece of code has been added to check the Work Order's Eligibility to be sent to
        ERP systems and set the Work Order as well as associated Repair Installation History Lines 
        Integration Status & Description accordingly - Anjali
        ******************************************************************************************/
        /*Final list<Id> woId = new list<Id>();//Integration Code start
        woId.add(workOrder.Id);
        String retString = SetWOIntegrationStatusHandler_MDSR.getWODetails(woId);
        if(retString != null && !string.isblank(retString)){
            //integrationStatus = retString;
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.WARNING, retString));
            integrationStatus = retString;
        }
        else
        {
            integrationStatus = '';
        }//Integration Code End*/
        //return recordURL;
    }
    
    public String redirectParam {get;set;}
    private String[] params;
    public void setRedirectParam() {
        params = redirectParam.split('#');
        PageReference pg = ApexPages.CurrentPage();
        pg.getParameters().put('state', params[0]);
        pg.setAnchor(params[1]);
        processAnchor();
    }
    public PageReference redirect() {
        PageReference pg = ApexPages.CurrentPage();
        pg.getParameters().put('state', params[0]);
        pg.setAnchor(params[1]);
        pg.setRedirect(true);
        return pg;
    }
    
    public PageReference cancel()
    {
        return recordURL;
    }
    
    private Map<String, String> getParametersFromAnchor(String anchor)
    {
        Map<String, String> parametersMap = new Map<String, String>();
        for(String anchorChunk : anchor.split('&'))
        {
            String[] parameters = anchorChunk.split('=');
            if(parameters.isEmpty())
                continue;
            parametersMap.put(parameters[0], parameters[1]);
        }
        return parametersMap;
    }
    @RemoteAction
    /*
        Parsing Logic,
        https://developer.pingidentity.com/en/resources/openid-connect-developers-guide/basic-client-profile.html
    */
    public static String verifyAuthentication(String URL)
    {
        String returnValue = Incorrect_Authentication;
        String[] urlChunks = url.split('#');

        if(urlChunks.size() == 2)
        {
            ESignRedirectionController_MDSR esrCtrl = new ESignRedirectionController_MDSR(false);
            String anchor = urlChunks[1];
            Map<String, String> parametersMap = esrCtrl.getParametersFromAnchor(anchor);
            String access_token = parametersMap.get('access_token');
            if(esrCtrl.verifyAccessToken(access_token))
            {
                String state = parametersMap.get('state');
                returnValue = state + '#' + anchor;
            }
        }
        return returnValue;
    }
    
    private Boolean verifyAccessToken(String access_token)
    {
        Boolean returnValue = false;
        try
        {
            LdapOAuth2Config__c ldapConfig = [SELECT ClientId__c, oAuth2Endpoint__c, Parameters__c, 
                Kid__c  FROM LdapOAuth2Config__c WHERE Name = 'PingIdentity'];
            User u = [SELECT Id, FederationIdentifier FROM User WHERE Id =:UserInfo.getUserId()];
            String[] accessTokenUnits = access_token.split('\\.');
            String headerb64 = accessTokenUnits[0];
            String payloadb64 = accessTokenUnits[1];
            //String digitalSignature = accessTokenUnits[2];
            
            Header headerValue = (Header)
                JSON.deserialize(EncodingUtil.base64Decode(headerb64).toString(), Header.Class);
            Payload payloadValue = (Payload)
                JSON.deserialize(EncodingUtil.base64Decode(payloadb64).toString(), Payload.Class);
                
            //String algorithm = headerValue.alg;
               
            Long expMS = payLoadValue.exp * 1000;
            DateTime expiry = DateTime.newInstance(expMS);
            
            if(ldapConfig.Kid__c != headerValue.kid || 
                ldapConfig.ClientId__c != payloadValue.client_id ||
                payloadValue.jnjMSUsername.toLowerCase() != u.FederationIdentifier.toLowerCase() ||
                payloadValue.mail.toLowerCase() != UserInfo.getUserEmail().toLowerCase() ||
                expiry < System.NOW())
            {
                returnValue = false;
            }
            else
            {
                returnValue = true;
            }
        }
        catch(StringException str)
        {
            returnValue = false;
        }
        return returnValue;
    }
    
    private class Header
    {
        String alg {get;set;}
        String kid {get;set;}
    }
    
    private class Payload
    {
        String jnjMSUsername {get;set;}
        String cn {get;set;}
        String sn {get;set;}
        String mail {get;set;}
        String givenName {get;set;}
        Long exp {get;set;}
        String [] scope {get;set;}
        String client_id {get;set;}
    }
    
}
Hi All i need help for the below lines to cover in the test class can you please help me to cover the class.

   public void autoPopulateSrcAccount(){
        if(rih.Source_Inventory__c != null)
        {         
           MedConnect__Inventory_Header__c invh =[select id,MedConnect__Location__c from MedConnect__Inventory_Header__c where Id =: rih.Source_Inventory__c];
           rih.Source_Account__c = invh.MedConnect__Location__c;
        }       
     }
    public void autoPopulatedesAccount(){
         if(rih.Destination_Inventory__c != null)
        {
           MedConnect__Inventory_Header__c invh =[select id,MedConnect__Location__c from MedConnect__Inventory_Header__c where Id =: rih.Destination_Inventory__c];
           rih.Destination_Account__c = invh.MedConnect__Location__c; 
        }
    }


thanks in Advance.
Hi All,

I am creating a email temaplate the below condition i gave for the subject.

{!IF(ISPICKVAL(MedConnect__Work_Order__c.Wo_Priority_MDSR__c,"") ,"","Priority : " )} {!MedConnect__Work_Order__c.Wo_Priority_MDSR__c} Escalation: Work Order- {!MedConnect__Work_Order__c.Name} is awaiting acceptance.

in this condition if the value is present in the MedConnect__Work_Order__c.Wo_Priority_MDSR__c then the priority verbiage will display otherwise it will be balnk now i want to dispaly the value of the preiory then verbaige priority if the value is present in the record otherwise it should be blank.
pls help me to correct this formula.

thanks
Hi All,

I am facing issue with approval process. 
1. Email is not sendi g once a approval request is created.
2. how to know  what are all the profile is having acess to a custom object.

Please help me to solve this.

Thanks in advance.
Hi All,

I have created a approval process on the quote custom object but the submit for approval button is not showin the UI. can you pls help me to complete the Approval Process.

Thanks in Advance.
Hi All,

Any Developer who can help me for the some bugs to be fixed for my development i have stucked in some of the develoment bugs. 

Please ping me anyone can help i will explain the issues which i am facing in my development.
please reply to this i can connect to discuss futher

Thanx in Advance.
Hi All,

I have lightning button and my requrement is to create the invoice on click of that button there are already logics are written on that button so i am facing some challenges to create the invoice and invoice line item pls help me to achieve this functionality. 
thanks in advance.
Hi All,

I want to display the subject in the Html email Template with the merge field.
This is below added in the subject part 
Escalation: Work Order- {!MedConnect__Work_Order__c.Name} is awaiting acceptance.
Now my requirement is before Escalation verbaige i want to display priority field value with the lable.
If value is not present in the field field label and value should not display.
pls help me to complete this
Thanks in Advance.
Hi All,

For the below Visualforce email template there is a priority field which needs to populate from the field value and the condition is if the value in the priority field is present then it has to popualte in template if value in the field is blank then priority should not display.  pls guide me how to acheive this. 
Thanks in advance.

<messaging:emailTemplate subject="Priority: {!relatedto.Wo_Priority_MDSR__c}  Action Required: You have been assigned to Work Order '{!relatedTo.name}'" recipientType="User" relatedToType="MedConnect__Work_Order__c">
<messaging:htmlEmailBody >
Hi All,

I am facing cylomatic complexcity for the below code pls help me to resolve this it is urgent pls. Thanx In advance


Public static void createOrderandOrderlintiem(List<MedConnect__Repair_Installation_History__c> rAIHList)
{
 
 List<string> repairid = new List<string>();
 Integer count = 0;
 List<string> assiID= new List<string>();
 List<MedConnect__Inventory_Request_Order__c> orderList = new List<MedConnect__Inventory_Request_Order__c>();
 List<String> WOIDList = new List<String>();
 List<MedConnect__Inventory_Request_Order__c> insertorder= new List<MedConnect__Inventory_Request_Order__c>();
 List<MedConnect__Inventory_Order_Line_Item__c> insertorderLineItem= new List<MedConnect__Inventory_Order_Line_Item__c>();
 Map< Integer,MedConnect__Repair_Installation_History__c> repairMap =new Map< Integer,MedConnect__Repair_Installation_History__c>();
 for(MedConnect__Repair_Installation_History__c rh:[select id,Destination_Account__c,Serialized_Part__c,Destination_Inventory__c,Lot_Number_MDSR__r.name,Condition__c,MedConnect__Source_Inventory__c,Lot_Number_MDSR__c,Product_Description_MDSR__c,MedConnect__Operation__c,Return_Flag_MDSR__c,MedConnect__Install_Uninstall__c,MedConnect__Repair_Analysis_And_Parts_Used__r.MedConnect__Work_Order__c,MedConnect__Asset__c,MedConnect__Asset__r.MedConnect__Product__c,Serialized_Part__r.MedConnect__Product__c from MedConnect__Repair_Installation_History__c where id in :rAIHList]){
   if(rh.MedConnect__Operation__c =='Uninstall' && rh.Return_Flag_MDSR__c ==true)
   {
       count++;
     repairid.add(rh.MedConnect__Repair_Analysis_And_Parts_Used__c);
     repairMap.put(count,rh);
     WOIDList.add(rh.MedConnect__Repair_Analysis_And_Parts_Used__r.MedConnect__Work_Order__c);
     
   }
 }
    if(!repairid.isEmpty()){
    List<MedConnect__Inventory_Request_Order__c> InvRequestOrder = [SELECT Id,MedConnect__Account__c, Is_Bulk_Uninstall_from_UI__c,MedConnect__Work_Order__r.MedConnect__Account__c,MedConnect__Work_Order__c FROM MedConnect__Inventory_Request_Order__c
                                                                   WHERE MedConnect__Work_Order__c IN :WOIDList AND Is_Bulk_Uninstall_from_UI__c=true];
    if(!InvRequestOrder.isEmpty()){
        orderList.add(InvRequestOrder.get(0));
    }
    else{
        for(MedConnect__Work_Order__c WO : [SELECT id,MedConnect__Account__c FROM MedConnect__Work_Order__c WHERE ID IN :WOIDList]){
             MedConnect__Inventory_Request_Order__c order = new MedConnect__Inventory_Request_Order__c();
            order.MedConnect__Work_Order__c = WO.Id;
            order.MedConnect__Account__c= WO.MedConnect__Account__c;
            order.Is_Bulk_Uninstall_from_UI__c = true;
            insertorder.add(order);
            orderList.add(order);
        }
         if(insertorder.size()>0){
            Database.SaveResult[] results = Database.insert(insertorder, false);
             for(Database.SaveResult res : results){
                 if(res.isSuccess()){
                 }
             }
    }
    }
 
      //Inserting order line item
        while(count>0){
         MedConnect__Inventory_Order_Line_Item__c oli = new MedConnect__Inventory_Order_Line_Item__c();
          oli.MedConnect__Order_Line_Type__c='Exchange In';
         // oli.MedConnect__Inventory_Request_Order__c=insertorder[0].Id;
          oli.MedConnect__Asset__c=repairMap.get(count).Serialized_Part__c;
          oli.MedConnect__Inventory_Request_Order__c = orderList.get(0).Id;
          oli.MedConnect__Product__c = repairMap.get(count).Serialized_Part__r.MedConnect__Product__c;
          oli.Lot_Batch_MDSR__c = repairMap.get(count).Lot_Number_MDSR__r.name;
          oli.MedConnect__Source_Inventory__c = repairMap.get(count).Destination_Inventory__c;
          oli.MedConnect__Source_Account__c = repairMap.get(count).Destination_Account__c;
           oli.MedConnect__Condition_Source__c = repairMap.get(count).Condition__c;
           
            insertorderLineItem.add(oli);
           count--;
        }
     
      if(insertorderLineItem.size()>0){
     try{
      Database.SaveResult[] results = Database.insert(insertorderLineItem, false);
             for(Database.SaveResult res : results){
                 if(res.isSuccess()){
                 }
             }
        }  
        catch(DMLException e){
       
      }
      }
    }
}
 
Hi All,

I Have a requirment to  auto create the record when when meeting certain condtion with specified values.

1. Create new order with the order line item type='exchange In'  condtion is there is a retun required field is is true.
2.In created order fileds should populate are Account (coming from thre work order object), Work Order from word order object.
3. Created Order Line Item with some fields like product from Asset 
Asset from Repair history object.

How we can acheive this is that flow will work here or coding we have to do or is there other way to do this. pls guide me its an urgent work.

Thanks in advance.
Hi All,

I have to display the fields based on the piclist selected value using lightning component.
example:" Patient envolvment" (picklist) is selected as yes it has to display the some fields like date, Additional contact Name and so on and when  " Patient envolvment" is no fields should hide. and once data is filled in the fields record should be created.
pls guide me how we can create in the lightning component.
this is bit urgent.
Thanks in advance.
Hi All,

Can you please tell me how can i write a condtion on this rule.

Condition: If Work order object's field which is product object's field Operation company is having perticular value or not. if it is having perticualr value then only validation needs to run otherwise no.

Rule :AND(ISNEW(), ISBLANK( TEXT( Patient_Involvement1_MDSR__c) ),ISBLANK(  TEXT(System_Malfunction_Deficiency1_MDSR__c ) ) )

needs to add the condition in this rule itself.
This is urgent pls.

Thnaks in advance.
I have a requirement  To develop timesheet application theses are the below sample screen which i have to develop this in lightning.

I have 3 objects contact,Timesheet,Absence.

when click on submit timesheet button quick action should display like below image.

User-added image

ejactly same UI should be and this data should fetch dynamically from contact record.
Hello all,

Need help to complete the test  class for the below class it has completed 52% now covering the create case but it is not covering.
please help me to complete this. 

Thanks in advance

Apex class:



public class CallDetailsController_LWCApex {
    
    @AuraEnabled(cacheable = true)
    public static Contact findContacts(String contactId) {
        return [SELECT FirstName,LastName,UserName__c,BusinessName__c,EIN__c,MobilePhone,Phone,Country__c,State__c,
               Email,Caller_Name__c,Caller_Phone__c FROM contact WHERE id =: contactId LIMIT 1];
    }
    
    @AuraEnabled
    public static void saveRequest(Call_Log__c Call,String contactId) {
        if(Call != NULL) {
            Contact newCon;
            if(Call.Select_User_Type__c == 'New User') {   
                 newCon = new Contact();
                newCon.FirstName = Call.First_Name__c;
                newCon.LastName = Call.Last_Name__c;
                newCon.UserName__c = Call.UserNameNew__c;
                newCon.BusinessName__c = Call.BusinessName__c;
                newCon.EIN__c = Call.EIN__c;
                newCon.MobilePhone = Call.CellPhone__c;
                newCon.Phone = Call.Phone_number__c;
                newCon.Email=Call.Email__c;
                newCon.Caller_Name__c=Call.Caller_Name_new__c;
                newCon.Caller_Phone__c=Call.Caller_Phone_new__c;
                newCon.Country__c = Call.Country__c;
                newCon.State__c = Call.State__c;
                try {
                     insert newCon;
                    
                }Catch(Exception e){
                     throw new AuraHandledException(e.getMessage());
                }      
            }
            
            //Create Call log;
            String callRecordTypeId  = Schema.getGlobalDescribe().get('Call_Log__c').getDescribe().getRecordTypeInfosByName().get(Call.Call_Type__c).getRecordTypeId();
            Call.RecordTypeId = callRecordTypeId;
            Call.Status__c ='New'; 
            
           /* if(String.isNotBlank(contactId) && Call.Select_User_Type__c != 'New User'){
                Call.Id = [SELECT Id FROM Call_Log__c WHERE Caller_Phone__c =:contactId LIMIT 1].Id;
            }
            else*/ if(newCon != NULL && newCon.Id != NULL) {
                 Call.Caller_Phone__c = newCon.Id;                
            }      
            try {
                insert Call;
            }Catch(Exception e){
                throw new AuraHandledException(e.getMessage());
            } 
            //Create Case
            Case newCase = new Case();        
            if(Call.Is_Follow_up_Required__c  == 'Yes') 
            {
                newCase.Status    = 'New';
                newCase.Subject = 'A new Inbound Case has been created';
                
                if(Call.Call_Type__c == 'Inbound')
                {
                    newCase.Subject = 'A new Inbound Case has been created';
                }
                else if (Call.Call_Type__c == 'Outbound')
                {
                    newCase.Subject = 'A new Outbound Case has been created';
                }
                
                else if (Call.Call_Type__c == 'Bulk Followup Upload')
                {
                    newCase.Subject = 'A new Followup Case has been created';
                }           
                else
                {
                    newCase.Subject = 'A new Follow Up Case has been created';
                }
            }        
            else{            
                newCase.Status = 'closed';
                newCase.Subject = 'A Case has been created';
            }        
            newCase.Assign_too__c= Call.Assign_too__c;
            newCase.Form_Type__c = Call.Form_Type__c;
            newCase.Purpose_of_the_Call__c = Call.Purpose_of_the_Call__c;
            newCase.Call_Deposition__c = Call.Call_Deposition__c;
            newCase.Remark_Comment__c = Call.Remark_Comment__c;
            newCase.Tax_Products__c = Call.Id;
            newCase.Created_By__c = Call.CreatedById;
            newCase.UserId__c = Call.UserNameNew__c;
            newCase.Phone__c =Call.Phone_number__c;
            if(newCon != NULL && newCon.Id != NULL)
                newCase.ContactId = newCon.Id;
            //   newCase.Ticket_Number__c = Call.Ticket_Number__c;
            try {
                insert newCase;
            }Catch(Exception e){
                throw new AuraHandledException(e.getMessage());
            } 
        }
    }
}.
Hello All,

I am having a apex class which is uploading the data to a custom object via csv file through vf page. 

I am checking a column into the csv file if it is valid only it has to insert the data but since it is coming into the for loop i am facing 101 error. please suggest me how to correct the code so that we this error can be avoid.

My code:

public class importDataFromCSVController {

public transient Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public transient List<Call_Log__c> acclist{get;set;}
List<String> failedLines;
Public Call_Log__c Call{get;set;}
public Integer totalunsuccessrec { get; set; }
public Integer totalsuccessrec { get; set; }
public string upload_err_msg{get; set;}
List<String> rows;
public String usernamelable {get;set;}
public integer totalrecords { get; set; }
public String fileName { get; set; }

   public importDataFromCSVController(){
    upload_err_msg='';
    csvFileLines = new String[]{};
    acclist = New List<Call_Log__c>(); 
    usernamelable = apexpages.currentpage().getparameters().get('att');
  }
  
  
 /**This function checks the validations in the vf page for the csv file. **/ 
  public PageReference importCSVFile(){
  
  
   acclist= new list<Call_Log__c >();
        failedlines = new list<string>();
        rows = new list<string>();  
        
        totalrecords =0;
        totalsuccessrec = 0;
        totalunsuccessrec = 0;
        
        try
        {
       
        if(csvFileBody!=null)
        {
            fileName = csvAsString;
           // csvAsString= csvAsString.toString();
            System.debug('csvAsString'+csvAsString);
                      
          //Convert the uploaded file which is in BLOB format into a string
            csvAsString = blobToString( csvFileBody,'ISO-8859-1');
           
          //Now sepatate every row of the csv file   
            csvFileLines = csvAsString.split('\n'); 
            
        }
                
        else{

            ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, 'Please choose a file to upload !'));
            return null;
        }

            acclist= uploadprocess();

        System.debug('aftrlist'+acclist);
            
        }
        
        Catch(Exception e)
        {     
            System.debug('e.getCause'+e.getCause());
            System.debug('e.getLinenumber'+e.getLinenumber());
            System.debug('e.getMessage'+e.getMessage());
            
            ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.Error,'The data in the file you have attempted to upload is not in the correct format and therefore did not upload successfully.'+'Cause:'+ e.getCause()+ 'Line:' +e.getLinenumber()+'  '+ 'Error Message:'+ '   ' + e.getMessage() );
            ApexPages.addMessage(errormsg);    
        }  
        
        System.debug('befsrlist'+acclist);
        Database.SaveResult[] srList ;                  
        if(acclist!=Null) {
        totalrecords = acclist.size(); 
        srList   = Database.insert(acclist, false);
        
        System.debug('srList'+srList);
        }
        
        if(srList!=Null){
        for(Database.SaveResult sr: srList)
        {
            if(!sr.IsSuccess())
            {    
                for(Database.Error err : sr.getErrors())
                {
                     ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.Error,'An error has occured while importing data Please make sure input csv file is correct.');
                     ApexPages.addMessage(errorMessage);      
                }
            }
        }           
       } 
        return null;  
    }
   
   
   
 /**This function reads the CSV file and inserts records into the calllog object. **/     
     public list<Call_Log__c > uploadprocess()
    {
    
     Integer counter = 1; 
        
    
              for(Integer i=1;i<csvFileLines.size();i++){
           
              Call_Log__c accObj = new Call_Log__c() ;
               
               accObj.Is_Bulk_Follow_up_Upload__c=true;
               accObj.Uploaded_By__c = usernamelable;
               accObj.Status__c='New';
               
               accObj.recordtypeid=label.Followuprecordtyopype;
               string[] csvRecordData = csvFileLines[i].split(',');
               
               
           //Mapping the Csv header with the fields.     
           
         //   List<Login__c> loginlist=[select Id,UserName__c from Login__c where UserName__c=:csvRecordData[23]];
           
          //  System.debug('Records on List are '+loginlist);
               
         //  if(loginlist.size()>0)
           
         //  {
               
               accObj.UserNameNew__c=csvRecordData[0];
               accObj.BusinessName__c=csvRecordData[1];
               accObj.EIN__c= csvRecordData[2];
               accObj.Phone_number__c= csvRecordData[3];
               accObj.CellPhone__c= csvRecordData[4];
               accObj.SA_Name__c= csvRecordData[5];
               accObj.First_Name__c= csvRecordData[6] ; 
               accObj.Last_Name__c= csvRecordData[7];  
               accObj.Email__c= csvRecordData[8];        
               accObj.Return_ID__c=csvRecordData[9];
               accObj.SKU__c=csvRecordData[10];
               accObj.Form_Type__c=csvRecordData[11];
               Datetime myDateTime = DateTime.valueof(csvRecordData[12]);
               String dtConverted = myDateTime.format('yyyy-MM-dd hh:mm:ss');
               accObj.Paid_Date__c= Datetime.valueof(dtConverted);
               accObj.Paid_Amount__c=csvRecordData[13];      
               Datetime myDateTim = DateTime.valueof(csvRecordData[14]);
               String dtConverte = myDateTim.format('yyyy-MM-dd hh:mm:ss');
               accObj.Registered_Date__c= Datetime.valueof(dtConverte);    
               accObj.Address__c=csvRecordData[15];
               accObj.City__c= csvRecordData[16]; 
               accObj.State__c = csvRecordData[17];
               accObj.Zip__c= csvRecordData[18];
               accObj.Country__c= csvRecordData[19];
               accObj.Time_Zone__c=(csvRecordData[20]);
               accObj.Others__c= csvRecordData[21];
               accObj.followup_type__c=csvRecordData[22];
                accObj.Assign__c= csvRecordData[23];
              
             
                                                                                       
               acclist.add(accObj);
               
              //}
               
               
               //else {
               // accObj.addError('Usename is not available Please provide the Correct Username');
               
              // }
             totalsuccessrec++;
              totalunsuccessrec++;
             
           }
            

            //Finally, insert the collected records
          //Database.insert(acclist,false);
          
             insert acclist;
             
                
       counter++; 
     System.debug('this has ' + acclist.size() + ' records total.');
     
     return null;
    
      } 
      
   
  
   /**
         This function convers the input CSV file in BLOB format into a string
        @param input    Blob data representing correct string in @inCharset encoding
        @param inCharset    encoding of the Blob data (for example 'ISO 8859-1')
     */
  
  public static String blobToString(Blob input, String inCharset){
        String hex = EncodingUtil.convertToHex(input);
        System.assertEquals(0, hex.length() & 1);
        final Integer bytesCount = hex.length() >> 1;
        String[] bytes = new String[bytesCount];
        for(Integer i = 0; i < bytesCount; ++i)
        bytes[i] =  hex.mid(i << 1, 2);
        return EncodingUtil.urlDecode('%' + String.join(bytes, '%'), inCharset);
    }
 
 
 
   public PageReference getViewrequest() 
    {
        pagereference ref4 = new pagereference('/apex/View_Request_Admin?att='+usernamelable);
        return ref4;
    }


    public String getFollowups() {
        return null;
    }


    public PageReference getReport() 
    {
     pagereference ref= new pagereference('/apex/TaxReport?att='+usernamelable ); 
     return ref;
        
    }


    public PageReference getCalllog() 
    {
         pagereference ref1= new pagereference('/apex/CallDetailsDashboard?att='+usernamelable);
        return ref1;
    }


    public PageReference getAddmembaer() 
    {
        pagereference ref3= new pagereference('/apex/Add_Member_Page?att='+usernamelable);
        return ref3;
    }


    public PageReference getProfile() 
    {
        pagereference ref2= new pagereference('/apex/Tax_Admin_Profile?att='+usernamelable);
        return ref2; 
    }

    public PageReference getUsers() 
    {
        pagereference ref5= new pagereference('/apex/Tax_View_Users_Admin?att='+usernamelable);
        return ref5; 
    }
    
    public PageReference getTicket() 
    {
         pagereference ref6= new pagereference('/apex/Tickets_Tax_Admin?att='+usernamelable);
        return ref6; 
    }

}User-added imagesee the image where i am facing the problem. this is the below code where i ma facing.


 //   List<Login__c> loginlist=[select Id,UserName__c from Login__c where UserName__c=:csvRecordData[23]];
           
          //  System.debug('Records on List are '+loginlist);
               
         //  if(loginlist.size()>0)
           


 
I have two obejct call log and login when i am inserting the data into the call log object using the csv upload i have a field called username we are inserting this field data from the csv file but before insertion this
username field data has to be validated if this username is matched with the login data it has to insert the record otherwise error to be display.

i have written a validation on the username field like below but this is giving the error for the condtion if username is correct also it is showing error.

Assign__c <> $ObjectType.Login__c.Fields.UserName__c

Assign__c  = field to be validate in the call log obejct
UserName__c  = field in the login obejct.

please help me here.

thanks in advance.
 
Hi All,

This is very urgent help.

I Have to insert the record from the visualforce page from a csv file  to the custom object called call_log and check all the valid calidations like if csv file is empty or not having the valid columns and after upload if any error is there need to export the error in the excel file. how to do this please help me witht the sample apex logic for this requirement.

Regards,
Priya Mishra
Hi All,

My requirement is to Uplaod the csv file through the vf page to custom object and the file header should be read the value which are saved in a custom object. like dynamic uplaod via vf page. please help me with the sample code.

Thanks in advance.
priya
Hi All,

I have a requriement where in the Dashboard Page i want to have a Picklist and Based on the Value selected from the Picklist (Piclist values : country, Task) the dashboard data should display.

can we acheive this using configutaion or we have to go for customization if customization how we can achieve this pls help me on this reuirement.

Thanks.
Hi All i need help for the below lines to cover in the test class can you please help me to cover the class.

   public void autoPopulateSrcAccount(){
        if(rih.Source_Inventory__c != null)
        {         
           MedConnect__Inventory_Header__c invh =[select id,MedConnect__Location__c from MedConnect__Inventory_Header__c where Id =: rih.Source_Inventory__c];
           rih.Source_Account__c = invh.MedConnect__Location__c;
        }       
     }
    public void autoPopulatedesAccount(){
         if(rih.Destination_Inventory__c != null)
        {
           MedConnect__Inventory_Header__c invh =[select id,MedConnect__Location__c from MedConnect__Inventory_Header__c where Id =: rih.Destination_Inventory__c];
           rih.Destination_Account__c = invh.MedConnect__Location__c; 
        }
    }


thanks in Advance.
Hi All,

I am facing issue with approval process. 
1. Email is not sendi g once a approval request is created.
2. how to know  what are all the profile is having acess to a custom object.

Please help me to solve this.

Thanks in advance.
Hi All,

I have created a approval process on the quote custom object but the submit for approval button is not showin the UI. can you pls help me to complete the Approval Process.

Thanks in Advance.
Hi All,

Any Developer who can help me for the some bugs to be fixed for my development i have stucked in some of the develoment bugs. 

Please ping me anyone can help i will explain the issues which i am facing in my development.
please reply to this i can connect to discuss futher

Thanx in Advance.
Hi All,

For the below Visualforce email template there is a priority field which needs to populate from the field value and the condition is if the value in the priority field is present then it has to popualte in template if value in the field is blank then priority should not display.  pls guide me how to acheive this. 
Thanks in advance.

<messaging:emailTemplate subject="Priority: {!relatedto.Wo_Priority_MDSR__c}  Action Required: You have been assigned to Work Order '{!relatedTo.name}'" recipientType="User" relatedToType="MedConnect__Work_Order__c">
<messaging:htmlEmailBody >
Hi All,

I am facing cylomatic complexcity for the below code pls help me to resolve this it is urgent pls. Thanx In advance


Public static void createOrderandOrderlintiem(List<MedConnect__Repair_Installation_History__c> rAIHList)
{
 
 List<string> repairid = new List<string>();
 Integer count = 0;
 List<string> assiID= new List<string>();
 List<MedConnect__Inventory_Request_Order__c> orderList = new List<MedConnect__Inventory_Request_Order__c>();
 List<String> WOIDList = new List<String>();
 List<MedConnect__Inventory_Request_Order__c> insertorder= new List<MedConnect__Inventory_Request_Order__c>();
 List<MedConnect__Inventory_Order_Line_Item__c> insertorderLineItem= new List<MedConnect__Inventory_Order_Line_Item__c>();
 Map< Integer,MedConnect__Repair_Installation_History__c> repairMap =new Map< Integer,MedConnect__Repair_Installation_History__c>();
 for(MedConnect__Repair_Installation_History__c rh:[select id,Destination_Account__c,Serialized_Part__c,Destination_Inventory__c,Lot_Number_MDSR__r.name,Condition__c,MedConnect__Source_Inventory__c,Lot_Number_MDSR__c,Product_Description_MDSR__c,MedConnect__Operation__c,Return_Flag_MDSR__c,MedConnect__Install_Uninstall__c,MedConnect__Repair_Analysis_And_Parts_Used__r.MedConnect__Work_Order__c,MedConnect__Asset__c,MedConnect__Asset__r.MedConnect__Product__c,Serialized_Part__r.MedConnect__Product__c from MedConnect__Repair_Installation_History__c where id in :rAIHList]){
   if(rh.MedConnect__Operation__c =='Uninstall' && rh.Return_Flag_MDSR__c ==true)
   {
       count++;
     repairid.add(rh.MedConnect__Repair_Analysis_And_Parts_Used__c);
     repairMap.put(count,rh);
     WOIDList.add(rh.MedConnect__Repair_Analysis_And_Parts_Used__r.MedConnect__Work_Order__c);
     
   }
 }
    if(!repairid.isEmpty()){
    List<MedConnect__Inventory_Request_Order__c> InvRequestOrder = [SELECT Id,MedConnect__Account__c, Is_Bulk_Uninstall_from_UI__c,MedConnect__Work_Order__r.MedConnect__Account__c,MedConnect__Work_Order__c FROM MedConnect__Inventory_Request_Order__c
                                                                   WHERE MedConnect__Work_Order__c IN :WOIDList AND Is_Bulk_Uninstall_from_UI__c=true];
    if(!InvRequestOrder.isEmpty()){
        orderList.add(InvRequestOrder.get(0));
    }
    else{
        for(MedConnect__Work_Order__c WO : [SELECT id,MedConnect__Account__c FROM MedConnect__Work_Order__c WHERE ID IN :WOIDList]){
             MedConnect__Inventory_Request_Order__c order = new MedConnect__Inventory_Request_Order__c();
            order.MedConnect__Work_Order__c = WO.Id;
            order.MedConnect__Account__c= WO.MedConnect__Account__c;
            order.Is_Bulk_Uninstall_from_UI__c = true;
            insertorder.add(order);
            orderList.add(order);
        }
         if(insertorder.size()>0){
            Database.SaveResult[] results = Database.insert(insertorder, false);
             for(Database.SaveResult res : results){
                 if(res.isSuccess()){
                 }
             }
    }
    }
 
      //Inserting order line item
        while(count>0){
         MedConnect__Inventory_Order_Line_Item__c oli = new MedConnect__Inventory_Order_Line_Item__c();
          oli.MedConnect__Order_Line_Type__c='Exchange In';
         // oli.MedConnect__Inventory_Request_Order__c=insertorder[0].Id;
          oli.MedConnect__Asset__c=repairMap.get(count).Serialized_Part__c;
          oli.MedConnect__Inventory_Request_Order__c = orderList.get(0).Id;
          oli.MedConnect__Product__c = repairMap.get(count).Serialized_Part__r.MedConnect__Product__c;
          oli.Lot_Batch_MDSR__c = repairMap.get(count).Lot_Number_MDSR__r.name;
          oli.MedConnect__Source_Inventory__c = repairMap.get(count).Destination_Inventory__c;
          oli.MedConnect__Source_Account__c = repairMap.get(count).Destination_Account__c;
           oli.MedConnect__Condition_Source__c = repairMap.get(count).Condition__c;
           
            insertorderLineItem.add(oli);
           count--;
        }
     
      if(insertorderLineItem.size()>0){
     try{
      Database.SaveResult[] results = Database.insert(insertorderLineItem, false);
             for(Database.SaveResult res : results){
                 if(res.isSuccess()){
                 }
             }
        }  
        catch(DMLException e){
       
      }
      }
    }
}
 
Hi All,

Can you please tell me how can i write a condtion on this rule.

Condition: If Work order object's field which is product object's field Operation company is having perticular value or not. if it is having perticualr value then only validation needs to run otherwise no.

Rule :AND(ISNEW(), ISBLANK( TEXT( Patient_Involvement1_MDSR__c) ),ISBLANK(  TEXT(System_Malfunction_Deficiency1_MDSR__c ) ) )

needs to add the condition in this rule itself.
This is urgent pls.

Thnaks in advance.
Hello all,

Need help to complete the test  class for the below class it has completed 52% now covering the create case but it is not covering.
please help me to complete this. 

Thanks in advance

Apex class:



public class CallDetailsController_LWCApex {
    
    @AuraEnabled(cacheable = true)
    public static Contact findContacts(String contactId) {
        return [SELECT FirstName,LastName,UserName__c,BusinessName__c,EIN__c,MobilePhone,Phone,Country__c,State__c,
               Email,Caller_Name__c,Caller_Phone__c FROM contact WHERE id =: contactId LIMIT 1];
    }
    
    @AuraEnabled
    public static void saveRequest(Call_Log__c Call,String contactId) {
        if(Call != NULL) {
            Contact newCon;
            if(Call.Select_User_Type__c == 'New User') {   
                 newCon = new Contact();
                newCon.FirstName = Call.First_Name__c;
                newCon.LastName = Call.Last_Name__c;
                newCon.UserName__c = Call.UserNameNew__c;
                newCon.BusinessName__c = Call.BusinessName__c;
                newCon.EIN__c = Call.EIN__c;
                newCon.MobilePhone = Call.CellPhone__c;
                newCon.Phone = Call.Phone_number__c;
                newCon.Email=Call.Email__c;
                newCon.Caller_Name__c=Call.Caller_Name_new__c;
                newCon.Caller_Phone__c=Call.Caller_Phone_new__c;
                newCon.Country__c = Call.Country__c;
                newCon.State__c = Call.State__c;
                try {
                     insert newCon;
                    
                }Catch(Exception e){
                     throw new AuraHandledException(e.getMessage());
                }      
            }
            
            //Create Call log;
            String callRecordTypeId  = Schema.getGlobalDescribe().get('Call_Log__c').getDescribe().getRecordTypeInfosByName().get(Call.Call_Type__c).getRecordTypeId();
            Call.RecordTypeId = callRecordTypeId;
            Call.Status__c ='New'; 
            
           /* if(String.isNotBlank(contactId) && Call.Select_User_Type__c != 'New User'){
                Call.Id = [SELECT Id FROM Call_Log__c WHERE Caller_Phone__c =:contactId LIMIT 1].Id;
            }
            else*/ if(newCon != NULL && newCon.Id != NULL) {
                 Call.Caller_Phone__c = newCon.Id;                
            }      
            try {
                insert Call;
            }Catch(Exception e){
                throw new AuraHandledException(e.getMessage());
            } 
            //Create Case
            Case newCase = new Case();        
            if(Call.Is_Follow_up_Required__c  == 'Yes') 
            {
                newCase.Status    = 'New';
                newCase.Subject = 'A new Inbound Case has been created';
                
                if(Call.Call_Type__c == 'Inbound')
                {
                    newCase.Subject = 'A new Inbound Case has been created';
                }
                else if (Call.Call_Type__c == 'Outbound')
                {
                    newCase.Subject = 'A new Outbound Case has been created';
                }
                
                else if (Call.Call_Type__c == 'Bulk Followup Upload')
                {
                    newCase.Subject = 'A new Followup Case has been created';
                }           
                else
                {
                    newCase.Subject = 'A new Follow Up Case has been created';
                }
            }        
            else{            
                newCase.Status = 'closed';
                newCase.Subject = 'A Case has been created';
            }        
            newCase.Assign_too__c= Call.Assign_too__c;
            newCase.Form_Type__c = Call.Form_Type__c;
            newCase.Purpose_of_the_Call__c = Call.Purpose_of_the_Call__c;
            newCase.Call_Deposition__c = Call.Call_Deposition__c;
            newCase.Remark_Comment__c = Call.Remark_Comment__c;
            newCase.Tax_Products__c = Call.Id;
            newCase.Created_By__c = Call.CreatedById;
            newCase.UserId__c = Call.UserNameNew__c;
            newCase.Phone__c =Call.Phone_number__c;
            if(newCon != NULL && newCon.Id != NULL)
                newCase.ContactId = newCon.Id;
            //   newCase.Ticket_Number__c = Call.Ticket_Number__c;
            try {
                insert newCase;
            }Catch(Exception e){
                throw new AuraHandledException(e.getMessage());
            } 
        }
    }
}.
Hi All,

This is very urgent help.

I Have to insert the record from the visualforce page from a csv file  to the custom object called call_log and check all the valid calidations like if csv file is empty or not having the valid columns and after upload if any error is there need to export the error in the excel file. how to do this please help me witht the sample apex logic for this requirement.

Regards,
Priya Mishra
Hi All,

My requirement is to Uplaod the csv file through the vf page to custom object and the file header should be read the value which are saved in a custom object. like dynamic uplaod via vf page. please help me with the sample code.

Thanks in advance.
priya
Hi All,

While autherise the org in Visual studio code i am faicng this error can you pleae help me to resolve this error.

i have insatalled CLI and set the envirnment variable.
insatlled salesforce extension pack as well but still not able to autherise with the below error.

error:


{ Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn cmd',
  path: 'cmd',
  spawnargs:
   [ '/c',
     'start',
     '""',
     '/b',
     'login.salesforce.com/services/oauth2/authorize?response_type=code^&client_id=PlatformCLI^&redirect_uri=http%3A%2F%2Flocalhost%3A1717%2FOauthRedirect^&state=9e27549e3106^&prompt=login^&scope=refresh_token%20api%20web^&code_challenge=REjVPthgj4hOKjTa7-qA4rKI7FnBThJ4cC26UdmoYI4' ] }
I have an inputFile field that the user can upload a file into (in this case, we are only using CSV files)
<apex:inputFile id="csvfield" value="" />

In the Javascript, I try to reference the uploaded CSV:
var csvfile = document.getElementById('{!$Component.csvform:out:csvfield}').value;
However, I'm not able to work with it because I'm not getting a Blob, but a String. 

How can I make csvfile be the Blob uploaded?