Capture all opportunity fields & send to PHP script - javascript

I am building an app that lets our sales team (who uses Salesforce) export to a new Evernote note with one click. I have the Evernote functionality already available in a PHP script I wrote, and I was planning on using Javascript to make an XHR to that script, but that is irrelevant at this point.
What I need to be able to do is capture all of the fields in the currently-open opportunity and upon clicking my custom button / link, capture all those fields as a javascript variable that I can then POST to my PHP app. Even a simple example of how I could go about capturing one field would be great -- I can't seem to find anything in the SalesForce documentation that covers this.

What you need here is an Apex callout. This doc on developer.force.com covers it OK, it's a starting point anyway (although it doesn't show you how to query for the fields of Opportunity -- you'll find that in the regular Apex docs under SOQL). For some sample code you might look at the Force.com Toolkit for Google APIs, which uses callouts pretty extensively (although you may need to wade through it a bit to find the relevant parts).
In any case, if you start by searching the docs on Apex callouts, that will probably get you rolling in the right direction.
Another method of doing this, incidentally, would be to wire up a custom button with the AJAX toolkit to compose the body of the post, and then post it and have your PHP page redirect the user back to where he started. That could work too, although my first inclination would be to do it in Apex instead.

Do they really have to click a button? What if meeting some condition would work?
I'm asking because Workflow rules (which are usually good for field updates, creation of Tasks or sending emails) have option to send out a SOAP message. It'd be a somewhat bloated XML but on the plus side - no coding needed, pure configuration. Plus - their delivery status can be tracked easily.
Check the help and at the very least you now have the keyword to Google for ;) Topic on consuming them on salesforce.stackexchange.com might also be useful.
If it has to be under a button - you probably could do with making a fake update of some helper field... Maybe even "count of messages sent"?

Related

Saving & embedding user's own javascript code

I'm hosting a small service where people can create online calendars. I'm playing with the idea of allowing users to save & embed their own javascript/html/css to their calendars.
I'm a bit worried about the security implications - are there ways to use XSS etc so that the users javascript code could affect some other calendars besides the one where the code is embedded?
From the customers perspective, the JS on the page should be allowed to change all the aspects of the page.
I guess the safest way would be to only allow custom HTML/CSS, but the ability to modify the layout and functionality of the calendar with JS would be a nice feature to have.
This can be very dangerous, for the same reason that
eval is evil
You're basically giving the user an oportunity to run malicious scripts.
Example: You are using AJAX to update something on your server. I come along, open up my trusty Firebug, see the AJAX request, and decide to wreck a little havoc, because thats what I do. I just rewrite the AJAX call, change the id of my calender to some random one, and bam, thats my dirty deed for the day.

Is there a library to handle form like in Google Contact

In Google Contacts, by default the form displays the values with some (read only) but when you click on a value, it converts the field into an so you can edit it, and when you press enter, it updates the value, remove the and redisplay the new value in the .
So it's really easy to add/modify information in one click.
I'm looking for a lib that do that, ideally that handle the whole process javascript+ajax+ror. Or just the javascript+ajax, or just javascript at least.
I think, like many of the other products, that they use GWT. Google Web Toolkit, its actually written in Java then cross compiled into Javascript. It allows them to write sourcecode for both the front and backend in Java and then creates optimised javascript for cross browsers.
The advantage of this is it is all widget based, and its super easy to switch components in and out without having to manually interact with the DOM.
However, if you do not wish to go down this route you can do it very simply in javascript using ajax calls. On a blur event you make an ajax call to your server which saves the field. On success it switches back to a Label. When you click on the label/text it switches for a textedit and uses the same contents as the label. No real need to use a plugin for this kind of thing as its actually pretty basic, it just looks good :).

How to make a simple event calendar in a c# MVC web project

I'm making a web page that has a calendar in it. It will be used as an event calendar, but I need the events info to come from a database, not hard coded. I also need it so it only displays the events (you can not add one) but when clicked it takes you to another web page (that will add it to the database). I need it this way because of user control. Only the user who creates the event should be able to delete or edit it(which is why I want it to go to another page).
I've been googleing like crazy but have not found anything I need. I did find a calendar called FullCalendar but I can't figure any way to get the events into it. They require an array of events but of course I can't use a server side variable like #Model.events or anything in the javascript. I also can't find one that doesn't allow everyone to edit or delete others posts (which is a security issue).
I'm not familiar with javascript so I have no idea how to get a variable form my database into the script.
Please help. I just want a very simple calendar that shows events that I can get from my own database. Hopefully one that allows hyperlinks as the events name so I can have it go to the events own page when clicked.
Thanks
While it's difficult to answer your question (as you have not provided any code as to what you have tried or researched so far), if you are looking for something simple, I would recommend looking at creating a web helper for your calendar. By doing this, you can do everything you are looking to do without having to use JavaScript. A starting (but very simple) example of a calendar web helper is found here: ASP.NET MVC Calendar Helper
However, might I also recommend that you spend some time learning JavaScript as there is quite a bit you can do to improve the user experience. But, as the previous example shows, you don't necessarily have to.
If I understood you correctly, you need some kind of a calendar where a user can manage his tasks. I can advise you a calendar that requires no knowledge of JavaScript, stores info to a database, and you can adjust access rights to your calendar (so if you need, only one user can make changes to it). It is described in this tutorial, and you can also check the demo. To my mind, it should be a good solution for you.

Take information from a text area and display it on separate page or put it in an array (Javascript)

For example I have a (feedback area) on my website, its a text area, when users type into this area and click a button, I would like Javascript to take thier information and write it to a feedback blank oage or place it in an array which I can use for a feedback update area
Any ideas thoughts??
This is what forms are designed to do. You are probably going to need a middle tier app like php, asp or coldfusion .
Using some server side scripting such as ASP, PHP etc as invertedSpear suggests will be the easiest way, would strongly suggest looking at the tutorials over at w3Schools or Tizag for code snippets.
Alternatively if your web hosting provider does not support server side programming (it's rare but some don't) then there may be a way using a Javascript / AJAX call and Yahoo Pipes to store the data and use JSON to display. However this is a method of last resort being way more complicated than a simple PHP form.

Javascript search widget with add/remove criteria

I'm looking for a FOSS Javascript widget which allows you to add/remove search criteria using a GUI.
My basis is the search criteria in Mac OS X Finder, but I know I've seen similar systems elsewhere:
alt text http://img714.imageshack.us/img714/579/screenshot20100429at805.png
The basic idea is that each row corresponds to one field in your database, and depending on the type of that field you would get different search options when you select it. You click the + and - buttons to add or remove fields.
Anybody aware of something like this that's already out there? Preferably written to work with YUI, but I don't mind transliterating from a JQuery or Dojo widget.
#lukecyca asked me to post a link to my implementation. This was written for an open source (GPL) project sponsored by a company that I no longer work for, so I can't guarantee that these links will stay up, but here goes.
The source code is currently on BitBucket. There's a client side (Javascript) library that is probably what you're most interested in, but there's also a server side (PHP) component that may be useful. It's pretty messy code (tightly coupled and really rushed), so I'm not sure it will even be useful, but there is a bit of documentation to help explain it. It's also been modified quite a bit since I left.
There's a demo server that's usually running if you want to see it in action. Please note that the username and password for the demo are listed on that page.

Categories

Resources