• Riby Varghese
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 0
    Replies

Hi I have picklist card status when selecting an inactivate field a seg card number is populated in another picklist.but try to save the details showing the error:: Validation Error: Value is not valid
function populateCard()
    {
        //alert('test');
         var accid = document.getElementById("LoyaltyPage:LoyaltyForm:loyaltyFormBlock:LoyaltySection1:LoyaltySectionItem1:targetId_lkid").value;
        Visualforce.remoting.Manager.invokeAction(
            '{!$RemoteAction.CaseLoyaltyCtrl.getCardNumber}',
            accid, 
            function(result,event){
                if (event.status) {
                     var x=document.getElementById("LoyaltyPage:LoyaltyForm:loyaltyFormBlock:j_id31:item2:j_id49:s1");
                    x.value="";
                    x.selectedIndex = 0;
                    
                    var optionlist =document.createElement("option");                                            
                   optionlist.text=result.Card_Number__c;
                     // option.text =cardno.Alias_Number__c ;
                     x.add(optionlist);
                }
            }, 
            {escape: true}
        );
          return true;
    }

Apex:

 @RemoteAction
    global static Account getCardNumber(String accountID) {
        Account account ;
  string soql = 'SELECT Card_number__c FROM Account WHERE Id=\''+accountID+'\'';
        account = Database.query(soql);
        System.debug('account'+account);
        return account;
    }

Hi, I have a picklist called appeasement type, but my Gift card is not showing in my picklist.
User-added image
User-added image
User-added image


User-added image

I have a picklist called Resolution type and appeasement type. Resolution type is dependent on appeasement type. My issue is that this field is not mandatory .but trying to save the case data it's not getting saved
 
Hi,
 I have a checkbox field called Pin_Status___c, and I want to use this field in output field, but it's not enabled when using it the output field.
          <apex:pageBlockSectionItem >
              <apex:outputLabel value="PIN" id="test">
                <!--<apex:panelGrid columns="2">-->
<apex:outputPanel>
                <!--<apex:inputField value="{!Account.PIN__c}" styleClass="omni" style="width: 55px;"/>-->
                <apex:outputField value="{!Account.PIN_Status__c}" styleClass="omni" id="test" />
                  </apex:outputPanel></apex:outputLabel>
               <!-- </apex:panelGrid>-->
          </apex:pageBlockSectionItem>
Hi,
I want to auto-populate phone number based on the account name selection from the lookup window.can anyone help?
Hi, I want to fire a trigger when the amount is greater  than 100, but it's not working 
trigger caseclosetrigger on Case(before insert) 
{
   //Loop Through All the records which are inside Trigger.new
   for(Case cs : Trigger.new)
   {
      //logic to check value
      if(cs.Appeasement_Type__c=='GoodWill Points')
      {
         if(cs.Appeasement_Amount__c <=100)
           {
        cs.addError('amount cant be less than 100');
           }
      }
   }
}
Customer id becomes null?? Can anyone help
 
    public CaseLoyaltyCtrl(ApexPages.StandardController stdController) { // Constructor
        stdCtrl=stdController;
        thisCase = (Case)stdCtrl.getRecord();
        customerID = ApexPages.currentPage().getParameters().get('id');
        System.debug('customerID==='+customerID);
        //if(!customerID.equalsIgnoreCase(null))
        if(!string.isEmpty(customerID))   
        {
           setCustomerName();
        }
        
        //thisAccount = (Account)stdController.getRecords();
        // System.debug('thisAccount.Name'+thisAccount.Name);
    }
hi i got this error when using test class.
@isTest(seeAllData=false)

public class CaseLoyalityTest {
@istest
     static  void testSearch() 
        
    {   Case acc = new Case();
        ApexPages.StandardController stc = new ApexPages.Standardcontroller(acc);
           CaseLoyaltyCtrl clc=new CaseLoyaltyCtrl(stc);
        
           clc.GetCustomer();
           clc.SaveLoyalty();
    }   
   
    @istest
     static  void testSearch1()     
    { 
    
        Case acc = new Case();
         acc.Phone_Number__c='8989098989';
        acc.Pin__c='test';
 
        ApexPages.StandardController stc = new ApexPages.Standardcontroller(acc);
        CaseLoyaltyCtrl clc=new CaseLoyaltyCtrl(stc);
           
             Test.startTest();
            Test.setMock(HttpCalloutMock.class, new MockPlentiResponseGenerator());
            clc.PINReset();
            Test.stopTest();
         
    }  
     @istest
     static void testSearch2() 
        
    {
        case acc=new case();
        ApexPages.StandardController stc = new ApexPages.Standardcontroller(acc);
           CaseLoyaltyCtrl clc=new CaseLoyaltyCtrl(stc);
           clc.GetAppcode('1');
        clc.GetAppcode('2');
        clc.GetAppcode('3');
           
         
    }  
     @istest
     static void testSearch3() 
        
    {
        case acc=new case();
        acc.Action__c='Password Reset';
        acc.Password__c='hai';
        ApexPages.StandardController stc = new ApexPages.Standardcontroller(acc);
           CaseLoyaltyCtrl clc=new CaseLoyaltyCtrl(stc);
       // clc.RstPassword();
     
 Test.setMock(HttpCalloutMock.class, new MockPlentiResponseGenerator());
            clc.RstPassword();
            Test.stopTest();
        
       

 
    }  
}


Apexclass
global with sharing class CaseLoyaltyCtrl{
      
    private ApexPages.StandardController stdCtrl;
    public  Case thisCase;
    Account thisAccount;
    Account selectedAccount;
    public String actionSelected {get; set;}
    public String accountLevelStatus {get; set;}
    PageReference pageRef;
    public String accountId {get; set;}
    public String cardNumber {get; set;}
    public String phoneNumber {get; set;}
    public String accountName {get; set;}
    string customerID {get;set;}
    
    public class CRCSearch
    {
        public String crcid {get; set;}
    }
    
    public class PasswordResetModel
    {
        public String crcId{get;set;}
        public String appCode{get;set;}
        public Boolean resetPassword{get;set;}
        public Boolean sendSMS{get;set;}
        public Boolean sendEmail{get;set;}
        public String templateType{get;set;}
    }
    public OmniOperations.Customer GetCustomer(){  // Customer search to get the customer and update the customer details
        
        // SearchOmniCtrl searchObj = new SearchOmniCtrl();
        // searchObj.doSearch();
        OmniOperations.Customer tempCust = new OmniOperations.Customer();
        return tempCust;
    }
    
    
    public CaseLoyaltyCtrl(ApexPages.StandardController stdController) { // Constructor
          stdCtrl=stdController;
        thisCase = (Case)stdController.getRecord();
        customerID = ApexPages.currentPage().getParameters().get('accid');
        System.debug('customerID==='+customerID);
        //if(!customerID.equalsIgnoreCase(null))
        if(!string.isEmpty(customerID))   
        {
           setCustomerName();
        }
        
        //thisAccount = (Account)stdController.getRecords();
        // System.debug('thisAccount.Name'+thisAccount.Name);
    }
     public void AccountPopulated()
 {
  Case cont=(Case) stdCtrl.getRecord();
  string soql = 'select id,Card_Number__c from Account  where id =\''+cont.Accountid+'\'';
  cont.Account  = Database.query(soql);
  //cont.Account=[select id, Site,phone__c from Account where id  = '0011F0000063GTiQAM'];
  cont.Card_Number__c =cont.Account.Card_Number__c;
 }
    private void setCustomerName()
    {
        if (!customerID.equalsIgnoreCase('') || customerID != null)
        {
            string soql = 'select Name from Account where id =\''+customerID+'\'';
            System.debug('soql'+soql);
            try
            {
                Account acc =  Database.query(soql);
                accountName = acc.Name;
            }
            catch(exception e){}
            
        }
    }
    public PageReference SaveLoyalty(){
        Boolean resStatus= false;
        Integer flag = 0; // flag to save case if no action is selected belore saving. Case can be also saved even if no action is selected.
        
        if(String.valueOf(thisCase.Action__c)  == 'Opt out of SMS')
        {
            flag = 1;
            resStatus = SetSMSOption();
            System.debug('IN SMS resStatus'+ resStatus);
        }
        else if(String.valueOf(thisCase.Action__c) == 'Pin Reset')
        {
            flag = 1;
            resStatus = PINReset();
            System.debug('IN PIN RST resStatus'+resStatus);
        }
        else if(String.valueOf(thisCase.Action__c) == 'Password Reset')
        {
            flag = 1;
            resStatus = RstPassword();
            System.debug('IN PASSWORD RST');
        }
        else if(String.valueOf(thisCase.Action__c) == 'Replacement Card')
        {
            flag = 1;
            resStatus = ReplaceCard();
            System.debug('IN REPLCMNT CARD resStatus');
        }
        else if(String.valueOf(thisCase.Action__c) == 'Account Status Update')
        {
            flag = 1;
            resStatus = SetAccountStatus();
            System.debug('IN ACU resStatus');
        }
        else
        {
            flag = 0;
            System.debug('No Action Selected');
        }
                
        PageReference p ; 
        if(resStatus)
        {
        try
        {
            
            thisCase.RecordTypeId=[Select Id From RecordType where DeveloperName ='Loyalty_SEG_Rewards' and SobjectType='case' limit 1].id;
            System.debug('thisCase.RecordTypeId===='+thisCase.RecordTypeId);
            System.debug('thisCase==='+thisCase);
            
            thisCase.AccountId=thisCase.accountid;
            if(thisCase.id == null)
            {
                Database.saveResult s = Database.insert(thisCase);
                p= new PageReference('/'+s.id);
                System.debug('s.id  1==='+s.id);
            }
            else
            {
                Database.saveResult s = Database.update(thisCase);
                p= new PageReference('/'+s.id);
                System.debug('s.id  2==='+s.id);
                
            }
            
            
        }
        catch(Exception e){}
        
        return p; 
           
        }
        else
        {
             //p= new PageReference();
        }
        return p; 
    }
    
    public Boolean RstPassword(){
        System.debug('thisCase.accountid====='+thisCase);
        String soql = 'select Card_Number__c,Member_ID__c,Chain_Id__c from account where id=\''+thisCase.accountid+'\'';
        
       
        //OmniOperations.Customer cust = new  OmniOperations.Customer();
       // cust.crcId = crcid;
        String reqBodyCust = '';
        /* reqBodyCust = JSON.serialize(cust,true);
        OmniOperations omniOps = new OmniOperations();
        HttpResponse result = omniOps.searchPlenti(reqBodyCust);
        System.debug('RstPassword Customer ====='+result.getBody());
        
        String reqBody = '';*/
        System.debug('RstPassword RES====='+thisCase.Action__c);
        
        CaseLoyaltyOperations loyaltyOps = new CaseLoyaltyOperations();
        PasswordResetModel passwordmodel = new PasswordResetModel();
         list<Account> rslt = Database.query(soql);
        passwordmodel.crcid = String.valueOf(rslt[0].Card_Number__c);
        string appCodenNum = GetAppcode(String.valueOf(rslt[0].Chain_Id__c));
        if(String.isNotEmpty(appCodenNum))
            passwordmodel.appCode = appCodenNum;
        passwordmodel.resetPassword = true;
        passwordmodel.sendSMS = true;
        passwordmodel.sendEmail = true; 
        passwordmodel.templateType = 'ResetPasswordAndCode';
       // OmniOperations.Customer customer = new OmniOperations.Customer();
        //fill the above customer object with necessary values.
      //  reqBody = JSON.serialize(result.getBody(),true);
       // System.debug('RstPassword reqBody====='+reqBody);
        
        HttpResponse res = loyaltyOps.ResetPassword(passwordmodel.crcId,passwordmodel.appCode,passwordmodel.resetPassword,passwordmodel.sendSMS,passwordmodel.sendEmail,passwordmodel.templateType);
        
        System.debug('RstPassword RES====='+res);
        
        if(res.getStatusCode() == 200)
        {
            return true;
        }
        else
        {
            return false;
        }        
    }
    
    public Boolean SetSMSOption(){
        System.debug('thisCase====='+thisCase);
        
        CaseLoyaltyOperations caseOps = new CaseLoyaltyOperations();
        OmniOperations.Customer customer = new OmniOperations.Customer();
        String soql = 'select Card_Number__c from account where id=\''+thisCase.accountid+'\'';
        list<Account> resu = Database.query(soql);
        String crcid = String.valueOf(resu[0].Card_Number__c);
        System.debug('crcid====='+crcid);
        HttpResponse res = caseOps.SetSMSOptInOut(crcid ,true);
        if(res.getStatusCode() == 200)
        {
            return true;
        }
        else
        {
            return false;
        }
        
    }
    
    public Boolean PINReset(){
        CaseLoyaltyOperations.PINReset pinrst = new CaseLoyaltyOperations.PINReset();
        CaseLoyaltyOperations caseOps = new CaseLoyaltyOperations();
        pinrst.Alias  =  Utils.extractDigitsFromPhone(thisCase.Phone_Number__c );
        //pinrst.Alias  = thisCase.Phone_Number__c;
        pinrst.AliasType = 3;
        pinrst.PinPassword = thisCase.Pin__c;
        pinrst.Source = 'CallCenter';
        
        String reqBody = JSON.serialize(pinrst,true);
        System.debug('PIN reqBody====='+reqBody);
        HttpResponse res = caseOps.ResetPIN(reqBody);
        System.debug('PIN RES====='+res.getBody());
        if(res.getStatusCode() == 200)
        {
            return true;
        }
        else
        {
            return false;
        }
        
    }
    
    public Boolean ReplaceCard(){
        
        System.debug('thisCase.accountid====='+thisCase);
        
        String soql = 'select Card_Number__c,Member_ID__c,Chain_Id__c,SEG_Rewards_Card_Number__c from account where id=\''+thisCase.accountid+'\'';
        
        list<Account> rslt = Database.query(soql);
        String crcid = String.valueOf(rslt[0].Card_Number__c);
        string memberID = String.valueOf(rslt[0].Member_ID__c);
        string SEGCardNumber = String.valueOf(rslt[0].SEG_Rewards_Card_Number__c);
        System.debug('thisCase.Replacement_Card__c==='+thisCase.Replacement_Card__c);
        
        //START: Below code is to prepare customer request obj
        CustomerSave.Customer customerObj = new CustomerSave.Customer();
        CustomerSave.Membership membershipObj = new  CustomerSave.Membership();
        List<CustomerSave.MemberAlias> memberaliasObj = new  List<CustomerSave.MemberAlias>();
        CustomerSave.MemberAlias tempMembr = new CustomerSave.MemberAlias();
        
        customerObj.crcId = crcid;
        customerObj.chainId = rslt[0].Chain_Id__c;
        customerObj.memberId = memberID;
        
        if(!string.isEmpty(SEGCardNumber) || !SEGCardNumber.equalsIgnoreCase('null'))
        {
            CustomerSave.MemberAlias membrSEGOld = new CustomerSave.MemberAlias();
            membrSEGOld.aliasNumber  =  SEGCardNumber;
            membrSEGOld.memberId = memberID;
            membrSEGOld.aliasType = '2';
            membrSEGOld.aliasStatus = '1';
            membrSEGOld.lastUpdateDate = null;
            membrSEGOld.lastUpdateSource = 'CUSTOMERCALLCENTER';
            memberaliasObj.Add(membrSEGOld);
        }
        
        tempMembr.aliasNumber  =  String.valueOf(thisCase.Replacement_Card__c);
        tempMembr.memberId = memberID;
        tempMembr.aliasType = '2';
        tempMembr.aliasStatus = '0';
        tempMembr.lastUpdateDate = null;
        tempMembr.lastUpdateSource = 'CUSTOMERCALLCENTER';
        
        memberaliasObj.Add(tempMembr);
        membershipObj.custAliasRecords = memberaliasObj;
        membershipObj.memberId = memberID;
        customerObj.membership = membershipObj;
        //STOP: Below code is to prepare customer request obj
        
        String reqBody = JSON.serialize(customerObj,true);
        System.debug('REPLCMNT CARD reqBody==='+reqBody);
        
        //OmniOperations omniOps = new OmniOperations();
        //HttpResponse res = omniOps.searchPlenti(reqBody);
        
        
        CaseLoyaltyOperations caseOps = new CaseLoyaltyOperations();
        HttpResponse result = caseOps.ReplaceCard(reqBody);
        //Update on ODS
        
        if(result.getStatusCode() == 200)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    
    public Boolean SetAccountStatus(){
        String soql = 'select Card_Number__c,Member_ID__c,Chain_Id__c,PIN_Status__c from account where id=\''+thisCase.accountid+'\'';
        list<Account> rslt = Database.query(soql);
        String crcid = String.valueOf(rslt[0].Card_Number__c);
        string chainId = String.valueOf(rslt[0].Chain_Id__c);
        String memberId = String.valueOf(rslt[0].Member_ID__c);
        boolean pinStatus = Boolean.valueOf(rslt[0].PIN_Status__c);
        System.Debug('PIN Status'+String.valueOf(rslt[0].PIN_Status__c));
        // in case of active we have to check PIN is set or not for the customer
        String enrollStatus = Utils.setEnrollmentStatusForLoyaltyCase(thisCase.Account_Level_Status__c);
        System.Debug('enrollStatus'+enrollStatus);
        //
        
        CustomerSave.Customer customerObj = new CustomerSave.Customer();
        CustomerSave.Membership membershipObj = new CustomerSave.Membership();
        
        
        customerObj.crcId = crcid;
        customerObj.memberId = memberId;
        customerObj.chainId = Decimal.valueOf(chainId);
        //customerObj.firstName = fname;
        //customerObj.lastName = lname;
        membershipObj.memberId = memberId;
        if (enrollStatus == 'E')
        {
            if(pinStatus)
            {
                membershipObj.enrollmentStatus = 'E';
            } 
            else
            {
                membershipObj.enrollmentStatus = 'P';
            }
        }
        else if (enrollStatus == 'B')
        {
            membershipObj.enrollmentStatus = 'B';
        }
        else if (enrollStatus == 'C')
        {
            membershipObj.enrollmentStatus = 'C';
        }
        membershipObj.lastUpdateSource = 'CUSTOMERCALLCENTER';
        customerObj.membership = membershipObj;
        
        String reqBody = JSON.serialize(customerObj,true);
        System.debug('SetAccountStatus  reqBody==='+reqBody);
        CaseLoyaltyOperations caseops = new CaseLoyaltyOperations();
        HttpResponse res = caseops.AccountStatusSet(reqBody);
        System.debug('SetAccountStatus  resBody==='+res.getBody());
        if(res.getStatusCode() == 200)
        {
            return true;
        }
        else
        {
            return false;
        }
        //update on ods.
    }
    
    public String GetAppcode(string appcodeNum){
        if(appcodeNum == '1')//WinDixie
        {
            return '003014';
        }
            
        else if(appcodeNum == '2')//Bi-Lo
        {
            return '013014';
        }
        else if(appcodeNum == '3')//Harveys
        {
            return '023014';
        }
        return null;
    }
    
    @RemoteAction
    global static Account getAccount(String accountID) {
        Account account ;
        string soql = 'SELECT Phone__c FROM Account WHERE Id=\''+accountID+'\'';
        account = Database.query(soql);
        return account;
    }
}
 I have a class called the customer with attributes first name and last name.and its list class called customer address with attributes alias type, alias number, and alias status.but every time I get the response, it will override the previous result.how to avoid this problem?
I want to hide the output label,only required the particular action is performed.
<apex:page standardController="Case">
    <apex:form >
        <apex:pageBlock >            
            <apex:pageBlockSection id="thePageBlockSection1">
            
                <apex:pageblockSectionItem >                    
                    <apex:outputLabel value="Action"></apex:outputLabel>
                    <apex:actionRegion >
                    <apex:inputField value="{!case.Action__c}">
                        <apex:actionSupport event="onchange" reRender="opTxt1, opTxt2, opTxt3"/>
                    </apex:inputField>
                    </apex:actionRegion>
                </apex:pageblockSectionItem>                
                <apex:pageblockSectionItem id="pbsItem1">                    
          <apex:outputLabel value="Pin" ></apex:outputLabel>
                    <apex:outputPanel id="opTxt1">
                        <apex:inputField id="pin" value="{!case.Pin__c}" rendered="{!if(case.Action__c== 'Pin Reset', true, false)}"/>
                    </apex:outputPanel>
                </apex:pageblockSectionItem>                
                <apex:pageblockSectionItem id="pbsItem2" >                    
     <apex:outputLabel ></apex:outputLabel>
                    <apex:outputPanel id="opTxt2">
                        <apex:inputField id="txt2" value="{!case.Password__c}" rendered="{!if(case.Action__c== 'Password Reset', true, false)}"/>
                    </apex:outputPanel>
                </apex:pageblockSectionItem>                
                <apex:pageblockSectionItem id="pbsItem3" >                    
                 <apex:outputLabel value="Text 3"></apex:outputLabel>
                    <apex:outputPanel id="opTxt3">
                        <apex:inputField label="text" id="txt3" value="{!case.Replacement_Card__c}" rendered="{!if(case.Action__c== 'Replacement Card', true, false)}"/>
                    </apex:outputPanel>
                </apex:pageblockSectionItem>                             
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Any Idea?
User-added image
Hi, I have a pick list with some values,based on the value a text box will appear and disappear.When i select password reset from the picklist ,its inputfield will appeared.But my problem is want to hide the input label.How its possible?
<apex:page standardController="Case">
    <apex:form >
        <apex:pageBlock >            
            <apex:pageBlockSection id="thePageBlockSection1">
            
                <apex:pageblockSectionItem >                    
                    <apex:outputLabel value="Action"></apex:outputLabel>
                    <apex:actionRegion >
                    <apex:inputField value="{!case.Action__c}">
                        <apex:actionSupport event="onchange" reRender="opTxt1, opTxt2, opTxt3"/>
                    </apex:inputField>
                    </apex:actionRegion>
                </apex:pageblockSectionItem>                
                <apex:pageblockSectionItem id="pbsItem1">                    
          <apex:outputLabel value="Pin" ></apex:outputLabel>
                    <apex:outputPanel id="opTxt1">
                        <apex:inputField id="pin" value="{!case.Pin__c}" rendered="{!if(case.Action__c== 'Pin Reset', true, false)}"/>
                    </apex:outputPanel>
                </apex:pageblockSectionItem>                
                <apex:pageblockSectionItem id="pbsItem2" >                    
          <apex:outputLabel value="Password"></apex:outputLabel>
                    <apex:outputPanel id="opTxt2">
                        <apex:inputField id="txt2" value="{!case.Password__c}" rendered="{!if(case.Action__c== 'Password Reset', true, false)}"/>
                    </apex:outputPanel>
                </apex:pageblockSectionItem>                
                <apex:pageblockSectionItem id="pbsItem3">                    
                 <apex:outputLabel value="Text 3"></apex:outputLabel>
                    <apex:outputPanel id="opTxt3">
                        <apex:inputField id="txt3" value="{!case.Replacement_Card__c}" rendered="{!if(case.Action__c== 'Replacement Card', true, false)}"/>
                    </apex:outputPanel>
                </apex:pageblockSectionItem>                             
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
This is my code
 <apex:pageBlockSection title="Loyality Changes" columns="2" collapsible="false">
                
                <apex:actionRegion >
                    <apex:outputLabel value="Action" for="Action" style="float:left"/>&nbsp;
                    <apex:inputfield value="{!case.Action__c}" id="Action">
                        <apex:actionSupport event="onchange" rerender="ProdFamilyModel"/> 
                    </apex:inputfield>
                </apex:actionRegion>
                 
        <apex:outputPanel id="ProdFamilyModel">
                
               <apex:inputField    value="{!case.Password__c}"  rendered="{!IF(case.Action__c == 'Password Reset', true, false)}"/>         
              <apex:inputField  value="{!case.Pin__c}" rendered="{!IF(case.Action__c == 'Pin Reset', true, false)}" />

       </apex:outputPanel>          
                 
              
                 
      </apex:pageBlockSection>