How to show Feed back message in sales force Standard page? - salesforce

I want to show a Feed back message in sales force Standard page on custom button click using visual force page on the basis of Apex class logic.Any one who can help me?For example if some thing successfully done then success message and if not error message should display on standard page.

You can create a new method to handle your messages
private void displayFeedback(ApexPages.Severity msgType, String message)
{
ApexPages.Message msg = new ApexPages.Message(msgType, message);
ApexPages.addMessage(msg);
}
Build your message you want to show..
displayFeedback(ApexPages.Severity.Error, String.valueOf(TripProfileHandlerServices.ERROR_SAVING_DATA + missingDataError));
Put this message in your VF page
<apex:pageMessages id="feedback" />
You will also have to rerender='feedback" when you want show the message after an event

If you put a <apex:messages /> in the page, you can use the message class to fill it up.

Related

Logic app connecting to MQ getting message item binary content instead of message item content

our Logic app connects to MQ and polls messages, for one of hte queue, I am seeing message in below format coming in Message item binary content,
{
"$content-type": "application/octet-stream",
"$content": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48bnM0aW9uVGV4dD4KICA8L0V4Y2VwdGlvbj4KPC9uczA6UG9saWN5VXBkYXRlPg==" //truncated value
}
How to get value from content in logic app?
Also for other queues message coming in Message item content and able to get text data correctly.
The issue got resolved after conneccting with MS Helpdesk, need to use string(Message item binary content) when reading messages, this will get decoded.

Merge fields won't show on visualforce page

I just started learning Apex recently, and there's still a lot of topics that are hard for me to navigate at this time. I've searched everywhere for a solution that works, but I still haven't been able to figure it out.
I've created a button on my Salesforce org that renders a PDF from a visualforce page, and attaches it to the record as a File. This is to be used with Docusign later on to capture signatures for contracts. The problem is that, when using merge fields in the VF page, they either do not show at all, or I get this exception: "sObject row was retrieved via SOQL without querying the requested field".
Now, the exception explicitly says that I need to query the fields, and this is what I've found I need to do to make this work, but I have not been able to figure out how to do this properly. I've tried running a query in several places in my controller extension to no avail (I am using a standardController that SF created for my custom object).
Here's my extension's code:
public class attachPDFToQuote {
public final i360__Quote__c q {get; set;} //Quote object
//constructor
public attachPDFToQuote (ApexPages.StandardController stdController) {
q = (i360__Quote__c)stdController.getRecord();
/* for(i360__Quote__c query:[SELECT Id, Correspondence_Name__c, Name FROM i360__Quote__c WHERE Id=: q.Id]){
System.debug(i360__Quote__c.Correspondence_Name__c);
}*/
}
public PageReference attachPDF() {
/* for(i360__Quote__c query:[SELECT Id, Correspondence_Name__c, Name FROM i360__Quote__c WHERE Id=: q.Id]){
System.debug(i360__Quote__c.Correspondence_Name__c);
}*/
//generate and attach the PDF document
PageReference pdfPage = Page.ProjectAgreement;
Blob pdfBlob; //create a blob for the PDF content
if (!Test.isRunningTest()) { //if we are not in testing context
pdfBlob = pdfPage.getContent(); //generate the pdf blob
} else { //otherwise, we are in testing context. Create the blob manually.
pdfBlob = Blob.valueOf('PDF');
}
ContentVersion cvAttach = new ContentVersion(ContentLocation= 'S');
cvAttach.PathOnClient= 'Project Agreement.pdf';
cvAttach.Title= 'Project Agreement';
cvAttach.VersionData= pdfBlob;
insert cvAttach;
Id conDoc = [SELECT ContentDocumentID FROM ContentVersion WHERE Id=: cvAttach.Id].ContentDocumentId;
ContentDocumentLink ConDocLink = new COntentDocumentLink();
conDocLink.LinkedEntityId= q.Id;
conDocLink.ContentDocumentId= conDoc;
conDocLink.ShareType= 'V';
insert conDocLink;
//redirect the user
PageReference pageWhereWeWantToGo = new ApexPages.StandardController(q).view(); //redirect the User back to the Quote detail page
pageWhereWeWantToGo.setRedirect(true); //indicate that the redirect should be performed on the client side
return pageWhereWeWantToGo; //send the User on their way
}
}
I kept the commented code where I try to query the object fields so they show in VF. I also tried a couple of different ways, but nothing seems to work. Please let me know if I need to add anything else.
Thank you!
You didn't post your Visualforce page's code.
Even if it's same page (if your apex class is used in ProjectAgreement VF as <apex:page standardController="i360__Quote__c" extensions="attachPDFToQuote" - the act of grabbing a PDF version of the page counts as callout, a separate http traffic to fresh instance of the page so to speak.
So I suspect you need something like
PageReference pdfPage = Page.ProjectAgreement;
pdfPage.getParameters().put('id', q.Id);
Blob = pdfPage.getContent();
If that works... next step would be to look at your VF code.
If the page has merge fields such as {!i360__Quote__c.Name}, {!i360__Quote__c.Correspondence_Name__c} then magic should happen. Salesforce should figure out which fields are needed by looking at your VF page and silently query them for you. So you wouldn't even need the query in your constructor, you could just save stdController.getId() to class variable and then use that id in pdfPage.getParameters().set(...)
But if your VF page has references to {!quote.Correspondence_Name__c} then you need to keep the explicit query in there.

VISUALFORCE /APEX : Simple email feedback form

I am developing a site in Visualforce and would like to offer user a simple form to send me feedback via email. There would be 3-4 fields like name, user's email, reason and feedback and "send" button. Clicking the send button should automatically send that message to my email address.
I do not want to store the form data in salesforce at least for now...All the stuff I found online about visualforce/apex and email is about saving that data to salesforce too.
Can I just make use of apex's email capabilities and send out email without storing that data anywhere in salesforce?
Thanks,
Calvin
It's not required to insert/update/delete any records in the database when executing an action on a VisualForce page. You can leverage the Outbound Email functionality to send out your notification. For something like this, you will probably want to familiarize yourself with the SingleEmailMessage methods.
A simple example to get you going:
public PageReference actionSend() {
String[] recipients = new String[]{'myemailaddress#somedomain.com'};
Messaging.reserveSingleEmailCapacity(recipients.size());
Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();
msg.setToAddresses(recipients);
msg.setSubject('Test Email Subject');
msg.setHtmlBody('Test body including HTML markup');
msg.setPlainTextBody('Test body excluding HTML markup');
msg.setSaveAsActivity(false);
msg.setUseSignature(false);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {msg}, false);
return null;
}
If you are interested in sending these outbound messages from a dedicated email address (something like noreply#somecompany.com), you can set these up through the Setup -> Administration Setup -> Email Administration -> Organization-Wide Addresses menu. Once you have created an org-wide address, grab the Id from the URL and use the setOrgWideEmailAddressId(Id) method on your instance of Messaging.SingleEmailMessage.

How to send key to click Yes button in WebDrive

When I activate a url via Webdrive that start up a Word Document a dialogbox with a Yes or No is started up .
How do I send in keys to click the Yes-button in Webdrive.
First you need to switch to the particular window using the following method -
WebDriver.switchTo().window()
If the name is not known, you can use
WebDriver.getWindowHandles()
to obtain a list of known windows. You may pass the handle to
switchTo().window().
If it's JavaScript you can use -
// Get a handle to the open alert, prompt or confirmation
Alert alert = driver.switchTo().alert();
// Get the text of the alert or prompt
alert.getText();
// And acknowledge the alert (equivalent to clicking "OK")
alert.accept();
Hope this helps!

ExtJS Custom Vtypes

Iam using Vtypes for Changpassword window.
My requirment is need to use only vtypes for all required/validations fields
So with out enter data clik on save its shows bubbles for required fields,but also show vtype for oldpassword not match.So how can use vtype after hitting database(From server) So is it possible?How
please provide some idea
Thanks in advance
You cannot use Ext.form.VTypes on the server unless you use some sort of JavaScript server (node.js with an ExtJS adapter - if there is one). You didn't mention the programming language you use on the server, so the answer is quite generic. To return errors from form posts that will be displayed as form field errors, your response to the form submit must conform to the following format:
{
success: false,
errors: {
oldpassword: "Your current password does not match"
}
}
The important part is the errors-structure. It contains key-value-pairs with the key being the name of the form field you'd like to display the error on and the value being the error message that will be displayed.

Resources