function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aidel BruckAidel Bruck 

Trying to update record using custom controller

I would like a visualforce page to display an alert and then update a field on the record. 
I am probably missing something here. 
Right now I am getting an error DML currently not allowed.

This is the VF page

<apex:page standardController="Other_Grant__c" extensions="MedicaidAlertController" >

  window.onload = function()
      var alertDisplayed="{!alertDisplayed}";
        if('{!Other_Grant__c.Medicaid_policies_count__c}'> 0 && alertDisplayed)
            alert('Patient has a medicaid insurance plan, please verify elibility for rides through insurance.');

This is the extension

public with sharing class MedicaidAlertController {

    Public id otherGrantid;
    Public Other_Grant__c otherGrantrec{get;set;}
    public boolean alertDisplayed{get;set;}
    Public Other_Grant__C OtherGrantToUpdate= new Other_Grant__C();

    public MedicaidAlertController (ApexPages.StandardController controller)     
     System.debug(' '+ alertDisplayed);
     otherGrantid = ApexPages.currentPage().getParameters().get('id');
     System.debug('Got ID: ' + otherGrantid);
        if(otherGrantid != null)
          otherGrantrec= [select id,Medicaid_Alert_Displayed__c from Other_Grant__C where id =:otherGrantid];
               System.debug(' '+ alertDisplayed);
          if(alertDisplayed== false)
   Public void updateAlertDisplayed(Boolean AlertDisplayed)
             if(alertDisplayed== false)
                Update OtherGrantToUpdate;
Aidel BruckAidel Bruck
In the article you sent me there seems to be a requirement to create a component. How do I pass the values of the current id to the action that is being used in the component? Aidel Bruck Salesforce Administrator and Developer Lead, RCCS +9722537983384 Create your own email signature