You need to sign in to do that
Don't have an account?
SFDC Apex Dev
Need help to convert the existing button code to vf and execute it through button at one click
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
{!requireScript("/soap/ajax/30.0/apex.js")}
var oppObj = new sforce.SObject("Opportunity");
oppObj.Id = '{!Opportunity.Id}';
var result = sforce.connection.update([oppObj]);
if (result[0].success=='false') {
alert(result[0].errors.message);
}
else {
sforce.apex.execute('ApexClass', 'methodName', {optyId:'{!Opportunity.Id}', action:'Default'});
alert('{!$Label.Success}');
}
}
document.location = '/{!Opportunity.Id}';
I've simply addeed the entire code to vf page, standardcontroller as Opportunity.
I need to use CSS as well so that the error msg can be displayed in left top instead of the alert box which displayed at the center on top.
Please help ASAP.
{!requireScript("/soap/ajax/30.0/apex.js")}
var oppObj = new sforce.SObject("Opportunity");
oppObj.Id = '{!Opportunity.Id}';
var result = sforce.connection.update([oppObj]);
if (result[0].success=='false') {
alert(result[0].errors.message);
}
else {
sforce.apex.execute('ApexClass', 'methodName', {optyId:'{!Opportunity.Id}', action:'Default'});
alert('{!$Label.Success}');
}
}
document.location = '/{!Opportunity.Id}';
I've simply addeed the entire code to vf page, standardcontroller as Opportunity.
I need to use CSS as well so that the error msg can be displayed in left top instead of the alert box which displayed at the center on top.
Please help ASAP.
Here the code I've written. Can you help me out to correct it using custom controller.
I want to show the error message or success message once we are clicking the button on opportunity and shoud show the message as per the screenshot.
<apex:pageMessages id="showmsg"></apex:pageMessages> this attribute.
Ex : Visual force page :
<apex:page standardController="Account" extensions="ErrorMessageInVfController">
<apex:form >
<apex:pageblock >
<apex:pageMessages id="showmsg"></apex:pageMessages>
Account Name: <apex:inputText value="{!acc.name}"/>
<apex:commandButton value="Update" action="{!save}" style="width:90px" rerender="showmsg"/>
</apex:pageblock>
</apex:form>
</apex:page>
Apex Page:
public with sharing class ErrorMessageInVfController {
public Account acc{get;set;}
public ErrorMessageInVfController(ApexPages.StandardController controller) {
acc = new Account();
}
public void save(){
if(acc.name == '' || acc.name == null){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Please enter Account name'));
}
// ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter Account name'));
// ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please enter Account name'));
// ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Please enter Account name'));
// ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Please enter Account name'));
}
}
https://prnt.sc/rn74g2
Logo looks like this : error, confirm etc.
Getting id you can pass your css for <apex:pageMessages>