• Corey Edwards 11
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 5
    Replies
I have a JSON string:
 
{addressDetails=({addressId=56941, addressLine1=76 Kilaben Rd, addressLine2=null, addressLine3=null, addressType=H, countryCode=AUS, locality=KILABEN BAY, postcode=2283, sortplan=017, state=NSW, ...}), aliasName=null, concessionInfo=null, contactDate=null, contactDetails=({contactDetail=, contactId=122827, contactType=H, delta=2}), contactPreference={correspondanceLevel=0, correspondanceLevelDescription=null, emailOpt=N, smsOpt=N}, deceasedFlag=N, dob=1952-07-29T00:00:00, firstContactDate=null, firstName=John, ...}
I'm mapping this using:
Map<String, Object> meta = (Map<String, Object>) JSON.deserializeUntyped(viewPersonValue);
To get firstname I'd say:
 
meta.get('firstName');
The issue I'm facing is accessing the values in addressDetails.
I've tried addressDetails[0] and addressDetails.addressId but I think I'm approaching this wrong.
Any help would be greatly appreciated.
 
Hi Guys,

I'm trying to convert my logic from jQuery to an Apex controller. Based on the changing values of my Visualforce page I'd want to return the correct value for my variable. Here is my code:
 
public with sharing class getPriceExtension {
    //Set Standard Controller
    ApexPages.standardController m_sc = null;
    
    //Set Quote Instance
    public Quote quo{get;set;} 
    
    //Set Global Variables
    String preHos = 'Premium Hospital',
            amb = 'Ambulance Only',
            firSta = 'First Start Hospital',
            fitHel = 'Fit & Healthy Hospital',
            pubHos = 'Public Hospital',
            smaHos = 'Smart Hospital',
            steUp = 'Step Up Hospital',
            valHos = 'Value Hospital',
            preExt = 'Premium Extras',
            smaExt = 'Smart Extras',
            valExt = 'Value Extras',
            fitExt = 'Fit & Healthy Extras',
            noHos = 'No Hospital',
            vicCor = 'Ambulance Victoria Corporate',
            vicRet = 'Ambulance Victoria Retail';
            Public Integer finalValue{get;set;}
    
    //Constructor
    public getPriceExtension(ApexPages.standardController sc)
    {
        m_sc = sc;
        quo = (Quote)sc.getRecord();
    }
    
    public Integer getHospitalId() {
        //Declare Locals
        String hospitalValue = quo.Hospital_Cover__c;
        String excess = quo.Excess__c;
        String levy = quo.Levy_Exempt__c;
        Integer f;
        
        //Logic
        //Premium Hospital
        if(hospitalValue == preHos) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                     f = 30;
                 } else{
                     f = 29;
                 }
            }
            if(excess == '$250') {
                if(levy == 'Yes') {
                    f = 9;
                } else {
                    f = 5;    
                }
            }
            if(excess == '$0') {
                if(levy == 'Yes') {
                    f = 8;
                } else {
                    f = 4;
                }
            }
        }
        //Smart Hospital
        if(hospitalValue == smaHos) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                    f = 22;
                } else {
                    f = 21;
                }
            } 
            if(excess == '$250') {
                if(levy == 'Yes'){
                    f = 28;
                } else {
                    f = 27;
                }
            }
        }
        //Step Up Hospital
        if(hospitalValue == steUp) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                    f = 41;
                } else {
                    f = 40;
                }
            }
            if(excess == '$250'){
                if(levy == 'Yes') {
                    f = 39;
                } else {
                    f = 38;
                }
            }
        }
        //First Start Hospital
        if(hospitalValue == firSta) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                    f = 45;
                } else {
                    f = 44;
                }
            }
            if(excess == '$250'){
                if(levy == 'Yes') {
                    f = 43;
                } else {
                    f = 42;
                }
            }
        }
        //Value Hospital
        if(hospitalValue == valHos) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                    f = 26;
                } else {
                    f = 25;
                }
            }
            if(excess == '$250'){
                if(levy == 'Yes') {
                    f = 24;
                } else {
                    f = 23;
                }
            }
        }
        //Public Hospital
        if(hospitalValue == pubHos) {
            f = 3;
        }
        //No Hospital
        if(hospitalValue == noHos) {
            f = 0;
        } 
        //Ambulance
        if(hospitalValue == amb) {
            f = 10;
        }
        //Fit & healthy
        if(hospitalValue == fitHel) {
            f = 6;
        }
        //Victoria Retail
        if(hospitalValue == vicRet) {
            f = 15;
        }
        //Victoria Corporate
        if(hospitalValue == vicCor) {
            f = 14;
        }
        finalValue = f;
        return finalValue;
    }
}

When I call this value in Visualforce using an actionFunction it doesn't return a value. I've tested assigning values through the controller and this method works. I understand that the state of my Quote object has something to do with this but am struggling to find a solution.

Cheers
Hi Guys,

I've created a Visualforce page which allows users to create quotes for customers. I want to create functionality which allows the user to adjust field values, click 'Save and New' and retain existing field values and create a new quote based on this. 

I can currently implement 'Save and new' functionality quite easily using:
 
public PageRedoSaveAndNew()
  {
    m_sc.save();
    
    PageReference pageRef = new PageReference(ApexPages.currentPage().getUrl());
    pageRef.setRedirect(true);
    return pageRef;
  }
I was hoping setting the Page Reference to the current page would help but it's not working. 

Any help would be greatly appreciated.

Cheers,

Corey
 

Hi Guys,

I'm trying to call an external API using a http class which looks like this:

String jsonBody = '{"CoverState":"NSW","CoverType":"S","HospitalProductId":29,"ExtrasProductId":34,"RebateFlag":"N","EffectiveDate":"12/02/2017","BillingFrequency":1,"Member1Age":0,"Member2Age":0,"payDirectDebit":"Y","maxAge":53,"rebateTier":3,"groupingid":0,"member1lhcPercentage":"46","member2lhcPercentage":"0","RebatePercent":0}';      
 String requestBody = JSON.serializePretty(jsonBody);   
 
 Http h = new Http();
    HttpRequest req = new HttpRequest();
    HttpResponse res = new HttpResponse();
 
 
    req.setEndpoint('http://10.x.x.xxx:xxxx/xxx/xxxx/xxxx');
    req.setMethod('POST');
    req.setHeader('Content-Type', 'application/json');       
    req.setBody(requestBody);

 System.Debug('@@@ req.getHeader'+req.getHeader('req.getHeader; '+'Content-Length'));
    System.Debug('@@@ req: '+req);
    System.Debug('@@@ req.getBody'+req.getBody());
   
 res = h.send(req);
 System.Debug('@@@ res: === '+res);
 
 String auth = res.getBody();
 System.Debug('@@@ Debug(auth:'+auth);

It's giving me a 403 forbidden error when a send this using the dev console in Salesforce.

I've set up a remote access URL in Salesforce and also enabled API for my account.

If anyone could help that would be greatly appreciated.

Cheers,
 

Corey

Hi Guys,

I've developed a Visualforce page using jQuery for click functionality throughout my page. This is used on the Quote object and values need to change within the page without the page reloading using Ajax requests. 

I'm new to Apex and have been asked to develop the page using Apex. Will I be able to get all the functionality available using Javascript using Apex?

Thankyou in advance for any help.

Corey
Hi Guys,

I'm trying to convert my logic from jQuery to an Apex controller. Based on the changing values of my Visualforce page I'd want to return the correct value for my variable. Here is my code:
 
public with sharing class getPriceExtension {
    //Set Standard Controller
    ApexPages.standardController m_sc = null;
    
    //Set Quote Instance
    public Quote quo{get;set;} 
    
    //Set Global Variables
    String preHos = 'Premium Hospital',
            amb = 'Ambulance Only',
            firSta = 'First Start Hospital',
            fitHel = 'Fit & Healthy Hospital',
            pubHos = 'Public Hospital',
            smaHos = 'Smart Hospital',
            steUp = 'Step Up Hospital',
            valHos = 'Value Hospital',
            preExt = 'Premium Extras',
            smaExt = 'Smart Extras',
            valExt = 'Value Extras',
            fitExt = 'Fit & Healthy Extras',
            noHos = 'No Hospital',
            vicCor = 'Ambulance Victoria Corporate',
            vicRet = 'Ambulance Victoria Retail';
            Public Integer finalValue{get;set;}
    
    //Constructor
    public getPriceExtension(ApexPages.standardController sc)
    {
        m_sc = sc;
        quo = (Quote)sc.getRecord();
    }
    
    public Integer getHospitalId() {
        //Declare Locals
        String hospitalValue = quo.Hospital_Cover__c;
        String excess = quo.Excess__c;
        String levy = quo.Levy_Exempt__c;
        Integer f;
        
        //Logic
        //Premium Hospital
        if(hospitalValue == preHos) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                     f = 30;
                 } else{
                     f = 29;
                 }
            }
            if(excess == '$250') {
                if(levy == 'Yes') {
                    f = 9;
                } else {
                    f = 5;    
                }
            }
            if(excess == '$0') {
                if(levy == 'Yes') {
                    f = 8;
                } else {
                    f = 4;
                }
            }
        }
        //Smart Hospital
        if(hospitalValue == smaHos) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                    f = 22;
                } else {
                    f = 21;
                }
            } 
            if(excess == '$250') {
                if(levy == 'Yes'){
                    f = 28;
                } else {
                    f = 27;
                }
            }
        }
        //Step Up Hospital
        if(hospitalValue == steUp) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                    f = 41;
                } else {
                    f = 40;
                }
            }
            if(excess == '$250'){
                if(levy == 'Yes') {
                    f = 39;
                } else {
                    f = 38;
                }
            }
        }
        //First Start Hospital
        if(hospitalValue == firSta) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                    f = 45;
                } else {
                    f = 44;
                }
            }
            if(excess == '$250'){
                if(levy == 'Yes') {
                    f = 43;
                } else {
                    f = 42;
                }
            }
        }
        //Value Hospital
        if(hospitalValue == valHos) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                    f = 26;
                } else {
                    f = 25;
                }
            }
            if(excess == '$250'){
                if(levy == 'Yes') {
                    f = 24;
                } else {
                    f = 23;
                }
            }
        }
        //Public Hospital
        if(hospitalValue == pubHos) {
            f = 3;
        }
        //No Hospital
        if(hospitalValue == noHos) {
            f = 0;
        } 
        //Ambulance
        if(hospitalValue == amb) {
            f = 10;
        }
        //Fit & healthy
        if(hospitalValue == fitHel) {
            f = 6;
        }
        //Victoria Retail
        if(hospitalValue == vicRet) {
            f = 15;
        }
        //Victoria Corporate
        if(hospitalValue == vicCor) {
            f = 14;
        }
        finalValue = f;
        return finalValue;
    }
}

When I call this value in Visualforce using an actionFunction it doesn't return a value. I've tested assigning values through the controller and this method works. I understand that the state of my Quote object has something to do with this but am struggling to find a solution.

Cheers
Hi Guys,

I'm trying to convert my logic from jQuery to an Apex controller. Based on the changing values of my Visualforce page I'd want to return the correct value for my variable. Here is my code:
 
public with sharing class getPriceExtension {
    //Set Standard Controller
    ApexPages.standardController m_sc = null;
    
    //Set Quote Instance
    public Quote quo{get;set;} 
    
    //Set Global Variables
    String preHos = 'Premium Hospital',
            amb = 'Ambulance Only',
            firSta = 'First Start Hospital',
            fitHel = 'Fit & Healthy Hospital',
            pubHos = 'Public Hospital',
            smaHos = 'Smart Hospital',
            steUp = 'Step Up Hospital',
            valHos = 'Value Hospital',
            preExt = 'Premium Extras',
            smaExt = 'Smart Extras',
            valExt = 'Value Extras',
            fitExt = 'Fit & Healthy Extras',
            noHos = 'No Hospital',
            vicCor = 'Ambulance Victoria Corporate',
            vicRet = 'Ambulance Victoria Retail';
            Public Integer finalValue{get;set;}
    
    //Constructor
    public getPriceExtension(ApexPages.standardController sc)
    {
        m_sc = sc;
        quo = (Quote)sc.getRecord();
    }
    
    public Integer getHospitalId() {
        //Declare Locals
        String hospitalValue = quo.Hospital_Cover__c;
        String excess = quo.Excess__c;
        String levy = quo.Levy_Exempt__c;
        Integer f;
        
        //Logic
        //Premium Hospital
        if(hospitalValue == preHos) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                     f = 30;
                 } else{
                     f = 29;
                 }
            }
            if(excess == '$250') {
                if(levy == 'Yes') {
                    f = 9;
                } else {
                    f = 5;    
                }
            }
            if(excess == '$0') {
                if(levy == 'Yes') {
                    f = 8;
                } else {
                    f = 4;
                }
            }
        }
        //Smart Hospital
        if(hospitalValue == smaHos) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                    f = 22;
                } else {
                    f = 21;
                }
            } 
            if(excess == '$250') {
                if(levy == 'Yes'){
                    f = 28;
                } else {
                    f = 27;
                }
            }
        }
        //Step Up Hospital
        if(hospitalValue == steUp) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                    f = 41;
                } else {
                    f = 40;
                }
            }
            if(excess == '$250'){
                if(levy == 'Yes') {
                    f = 39;
                } else {
                    f = 38;
                }
            }
        }
        //First Start Hospital
        if(hospitalValue == firSta) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                    f = 45;
                } else {
                    f = 44;
                }
            }
            if(excess == '$250'){
                if(levy == 'Yes') {
                    f = 43;
                } else {
                    f = 42;
                }
            }
        }
        //Value Hospital
        if(hospitalValue == valHos) {
            if(excess == '$500'){
                if(levy == 'Yes') {
                    f = 26;
                } else {
                    f = 25;
                }
            }
            if(excess == '$250'){
                if(levy == 'Yes') {
                    f = 24;
                } else {
                    f = 23;
                }
            }
        }
        //Public Hospital
        if(hospitalValue == pubHos) {
            f = 3;
        }
        //No Hospital
        if(hospitalValue == noHos) {
            f = 0;
        } 
        //Ambulance
        if(hospitalValue == amb) {
            f = 10;
        }
        //Fit & healthy
        if(hospitalValue == fitHel) {
            f = 6;
        }
        //Victoria Retail
        if(hospitalValue == vicRet) {
            f = 15;
        }
        //Victoria Corporate
        if(hospitalValue == vicCor) {
            f = 14;
        }
        finalValue = f;
        return finalValue;
    }
}

When I call this value in Visualforce using an actionFunction it doesn't return a value. I've tested assigning values through the controller and this method works. I understand that the state of my Quote object has something to do with this but am struggling to find a solution.

Cheers
Hi Guys,

I've created a Visualforce page which allows users to create quotes for customers. I want to create functionality which allows the user to adjust field values, click 'Save and New' and retain existing field values and create a new quote based on this. 

I can currently implement 'Save and new' functionality quite easily using:
 
public PageRedoSaveAndNew()
  {
    m_sc.save();
    
    PageReference pageRef = new PageReference(ApexPages.currentPage().getUrl());
    pageRef.setRedirect(true);
    return pageRef;
  }
I was hoping setting the Page Reference to the current page would help but it's not working. 

Any help would be greatly appreciated.

Cheers,

Corey
 
We have a customized opportunity view page that overrides standard page in our SF. And now we need to add a controlling dependent list to this page:

Controlling field (picklist): Re-sign term
Dependent field (multi-select picklist): Re-sign Notice Period

We also have another text field: Re-sign term (other)

Our logic is if Re-sign term picklist value equals to 'Other', Re-sign term (other) textbox shoud be displayed, otherwise, keep hidden. We are trying to use Jquery to achieve this, but unfortunately, Jquery .change() event seems not working on this case (Re-sign term value changed, jquery is not triggerred). 

However, if we remove the field dependency, it is working fine. 

Any advices?