• Christopher Peck 16
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
I'm new to visualforce but trying to edit a page built by another. I need to set a picklist value, that can be changed on the form, to a value defined in the URL.

The URL that is pass includes:

?channel=email&market=1&lang=en

I'm trying to set the market picklist here:

<div class="new-subform-component form-group field">
     <label for="select_market" class="control-label id="select_market">{!$Label.Select_Market}:</label>
     <div>
          <apex:inputField value="{!caseObj.Case_Market__c}"
               Styleclass="form-control caseMarket" required="true" id="market" onchange="UpdateCountryCode()" />
     </div>
</div>

This is pulling the options from the Case.Case_Market__c field. Each Market(Country) as an API value that is a number but of course the number is considered text type.

If I add an onload function:

window.onload=function() {
                $('.caseMarket').val('1');
        };

This works, 1 = USA

Anything refencing the URL parameter, doesn't work such as:

var xMarket = '{($CurrentPage.parameters.market == null, '1', $CurrentPage.parameters.market)}';

window.onload=function() {
            if (xMarket == "1"){
                $('.caseMarket').val('1');
            } else if (xMarket == "2") {
                $('.caseMarket').val('2');
            }
            UpdateCountryCode()
        };

Or setting the .caseMarket by parameter on load:

window.onload=function() {
     $('.caseMarket').val('$CurrentPage.parameters.market');
}

I have tried many, many different ways of doing this, all failing. Ideas?
This should be simple and have found multiple examples but my situation is simply this, I want to update a Case field in Apex. There are actually two fields:

Disposition__c (picklist)
PC_Parent__c (Boolean)

parentCaseId is a variant is successfully passed. I have tried many examples found including the article:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_examples_insert_update.htm

every time I try a queryresult.Disposition__c, for example, I get the error when saving:

Error: Compile Error: Variable does not exist: Disposition__c at line xx column xx

An example of the full part of Apex is:

Id u = (Id)childCase.getField('Id');
    childCase = AccessControl.encapsulate([
    SELECT CaseNumber, ParentId, AccountId, ContactId, Disposition__c
    FROM Case
    WHERE Id = :u
    ]);
            
    childCase.Disposition__c = disposition;
            
    update childCase;
Hi all, new to Apex and am stuck. I'm getting the error:

    Error: Compile Error: Variable does not exist: Disposition__c at line 354 column 23    

Here is the relevant part of the code:

@AuraEnabled
    public static Map<String, Object> createChildCase (Id parentCaseId, Id accountId, Id contactId, String inquiry, String disposition, String trending, String Market, String language, String origin) {

        // Check execution context; must be internal user
        if (!AccessControl.isInternalContext()) {
            throw new AccessControl.ContextException();  // Roll back the transaction
        }

        try {

            AccessControl.Model parentCase = AccessControl.encapsulate([
                SELECT CaseNumber
                FROM Case
                WHERE Id = :parentCaseId
            ]);

            // Create child case
            AccessControl.Model childCase = AccessControl.create(Case.getSObjectType());
            childCase.setField('ParentId', parentCaseId);
            childCase.setField('AccountId', accountId);
            childCase.setField('ContactId', contactId);
            childCase.setField('Inquiry_Type__c', inquiry);
            childCase.setField('Trending__c', trending);
            childCase.setField('Case_Language__c', language);
            childCase.setField('Origin', origin);
            childCase.dmlInsert();

            // Retrieve the case record
            Id i = (Id)childCase.getField('Id');
            childCase = AccessControl.encapsulate([
                SELECT CaseNumber, ParentId, AccountId, ContactId
                FROM Case
                WHERE Id = :i
            ]);
                
            childCase.Disposition__c = disposition;
            update childCase;

Disposition__c is a field in the case object and not a variable.
Hi all, new to Apex and am stuck. I'm getting the error:

    Error: Compile Error: Variable does not exist: Disposition__c at line 354 column 23    

Here is the relevant part of the code:

@AuraEnabled
    public static Map<String, Object> createChildCase (Id parentCaseId, Id accountId, Id contactId, String inquiry, String disposition, String trending, String Market, String language, String origin) {

        // Check execution context; must be internal user
        if (!AccessControl.isInternalContext()) {
            throw new AccessControl.ContextException();  // Roll back the transaction
        }

        try {

            AccessControl.Model parentCase = AccessControl.encapsulate([
                SELECT CaseNumber
                FROM Case
                WHERE Id = :parentCaseId
            ]);

            // Create child case
            AccessControl.Model childCase = AccessControl.create(Case.getSObjectType());
            childCase.setField('ParentId', parentCaseId);
            childCase.setField('AccountId', accountId);
            childCase.setField('ContactId', contactId);
            childCase.setField('Inquiry_Type__c', inquiry);
            childCase.setField('Trending__c', trending);
            childCase.setField('Case_Language__c', language);
            childCase.setField('Origin', origin);
            childCase.dmlInsert();

            // Retrieve the case record
            Id i = (Id)childCase.getField('Id');
            childCase = AccessControl.encapsulate([
                SELECT CaseNumber, ParentId, AccountId, ContactId
                FROM Case
                WHERE Id = :i
            ]);
                
            childCase.Disposition__c = disposition;
            update childCase;

Disposition__c is a field in the case object and not a variable.