You need to sign in to do that
Don't have an account?
Aidel Bruck
Trying to update record using custom controller
Hi,
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" >
<script>
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.');
}
</script>
</apex:page>
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];
alertDisplayed=otherGrantrec.Medicaid_Alert_Displayed__c;
System.debug(' '+ alertDisplayed);
if(alertDisplayed== false)
UpdateAlertDisplayed(AlertDisplayed);
}
}
Public void updateAlertDisplayed(Boolean AlertDisplayed)
{
if(alertDisplayed== false)
OtherGrantToUpdate.id= othergrantrec.Id;
OtherGrantToUpdate.Medicaid_Alert_Displayed__c=true;
Update OtherGrantToUpdate;
}
}
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" >
<script>
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.');
}
</script>
</apex:page>
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];
alertDisplayed=otherGrantrec.Medicaid_Alert_Displayed__c;
System.debug(' '+ alertDisplayed);
if(alertDisplayed== false)
UpdateAlertDisplayed(AlertDisplayed);
}
}
Public void updateAlertDisplayed(Boolean AlertDisplayed)
{
if(alertDisplayed== false)
OtherGrantToUpdate.id= othergrantrec.Id;
OtherGrantToUpdate.Medicaid_Alert_Displayed__c=true;
Update OtherGrantToUpdate;
}
}
Aidel 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