//author : kkbes public with sharing class LexInquiryController { @AuraEnabled public static Task init(String recordId){ Task res = new Task(); try{ res=[SELECT Id,Related_Opportunity1__c,QuoteIraiId__c ,Status FROM Task WHERE Id = : recordId ]; } catch(Exception e){ System.debug(LoggingLevel.INFO, '*** e: ' + e); } return res; } @AuraEnabled public static List getOpportunityIds(String RelatedOpportunity1){ List res = new List(); try{ res=[SELECT id FROM Opportunity WHERE Opportunity_No__c = : RelatedOpportunity1]; } catch(Exception e){ System.debug(LoggingLevel.INFO, '*** e: ' + e); } return res; } @AuraEnabled public static QuoteIrai__c getQuoteIrai(String QuoteIraiId){ QuoteIrai__c res = new QuoteIrai__c(); try{ res=[SELECT Id,Lead__r.Opp_Name_Search__c,Lead__c FROM QuoteIrai__c WHERE Id = : QuoteIraiId ]; } catch(Exception e){ System.debug(LoggingLevel.INFO, '*** e: ' + e); } return res; } @AuraEnabled public static String makeAndUpdateLead(String leadId,String Id,String QuoteIraiId){ Lead res = new Lead(); try{ res.Id = Id; res.Opp_Name_Search__c = leadId; if(QuoteIraiId != ''){ res.LatestQuotationEntrustment__c=QuoteIraiId; } update res; return 'success'; } catch(Exception e){ String messageText=''; if(e.getMessage().contains(':')){ String eMessage =e.getMessage(); Integer left = eMessage.indexOf(',')+1; Integer right= eMessage.lastIndexOf(':')+1; if(right>eMessage.length()||right<=left){ right=eMessage.length(); } String mes=eMessage.substring(left,right); messageText = mes; return messageText; }else{ messageText=e.getMessage(); return messageText; } } } @AuraEnabled public static String makeAndUpdateTask(String Status,String Id){ Task res = new Task(); try{ res.Id = Id; res.Status = Status; res.Quotation_request_completed_time__c = System.now(); update res; return 'success'; } catch(Exception e){ String messageText=''; if(e.getMessage().contains(':')){ String eMessage =e.getMessage(); Integer left = eMessage.indexOf(',')+1; Integer right= eMessage.lastIndexOf(':')+1; if(right>eMessage.length()||right<=left){ right=eMessage.length(); } String mes=eMessage.substring(left,right); messageText = mes; return messageText; }else{ messageText=e.getMessage(); return messageText; } } } @AuraEnabled public static String makeAndUpdateQuoteIrai(String QuoteIraiStatus,String Id){ QuoteIrai__c res = new QuoteIrai__c(); try{ res.Id = Id; res.QuoteIrai_Status__c = QuoteIraiStatus; update res; return 'success'; } catch(Exception e){ String messageText=''; if(e.getMessage().contains(':')){ String eMessage =e.getMessage(); Integer left = eMessage.indexOf(',')+1; Integer right= eMessage.lastIndexOf(':')+1; if(right>eMessage.length()||right<=left){ right=eMessage.length(); } String mes=eMessage.substring(left,right); messageText = mes; return messageText; }else{ messageText=e.getMessage(); return messageText; } } } }