• Sonam_SFDC
  • ALL STAR
  • 6047 Points
  • Member since 2013
  • Salesforce.com

  • Chatter
    Feed
  • 186
    Best Answers
  • 0
    Likes Received
  • 11
    Likes Given
  • 0
    Questions
  • 2015
    Replies
Hello,

Does anyone know if it's possible to submit a record for approval using a custom button?  I would like to create three different approval processes where each approval process would have it's own custom submission button.

Each approval process would have the same entry criteria. Depending on which approval button the users clicks that record would be submitted for approval using the approval process tied to that particular custom approval button.

So instead of having just a single "Submit for Approval" button there would be three different buttons that the users could click to kickoff an approval process.

Any feedback would be greatly appreciated.

Thank you!
  • September 03, 2014
  • Like
  • 1

Hello

I've register as developer here: https://developer.salesforce.com/

Now I want to generate WSDL file and download it. I followed this instruction: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_quickstart_steps_generate_wsdl.htm

But when I go to Develop | API I see next picture: https://www.dropbox.com/s/udpap8f648adi5c/salesforce.jpg?dl=0

Could you explain what I did wrong? How can I get WSDL?

Hi All,

Please provide any documents or links to upload salesforce app in AppExchange.

Thanks.
Hi Everybody,
         Can anyone tell me how to use Database methods in try catch block ??
Please Give some example


Thanks in advance
Karthick

Error Error: Unknown property 'Contact__c.Miles__c' referenced in MyMileagePage

 

<apex:page >
  <!-- Begin Default Content REMOVE THIS -->
  <h1>{!$User.FirstName}'s Mileage Perspective</h1>
  <apex:detail/>
  <apex:detail subject="{!Contact__c.Miles__c}" />   
     
</apex:page>
I received email with subject "Warning: Page Views Are at 105% of Your Limit".
I found PDF with this limit value but I don't understand who I can check how many pages were view at this moment.
On path "Develop > Sites > ~Our site label~ I can see only block "24-Hour Usage History" with metrics: "Origin Bandwidth" and "Request Time". Where I can see the count of sales force page views?

Warning message from email:
Dear Administrator: Our records indicate that your Force.com sites are close to your organization's monthly page view limit. This limit is cumulative for all the sites within your organization. Your current usage is at 105% of your current monthly page view limit of 500,000. If you exceed your monthly page view limit for your organization, your Force.com sites may be shut down until the next calendar month.
  • August 20, 2014
  • Like
  • 0
Hi Everyone,
  I have problem in importing existing project in force.com.IDE
The problem is:
User-added image
so Can anyone tell me how to fix that problem

Please Help
I have contact_update_fiels__c field in account when update or insert record in account the field value should be copied to all related contacts field update_from_account__c its not updating with below code 

trigger rt on Account (after insert,after update)
{
set<id> set1=new set<id>();
  list<contact> conlistnew=new list<contact>();
  for(account acc:trigger.new)
  {
    set1.add(acc.id);
  } 
  list<contact> conlist=[select id,name,accountid from contact where accountid in:set1];
 
  for(account tempacc:trigger.new)
  {
  for(contact tempcon:conlist)
  {
   if(tempacc.id==tempcon.id)
   {
   tempacc.contact_update_fiels__c=tempcon.update_from_account__c;
   conlistnew.add(tempcon);
   }
  }
  }
  update conlistnew;
}
I'm looking at changing a Lookup Relationship to a Master-Detail relationship between Accounts and Assets.  What is the downside to this for an instance that has been operating for a LONG time.  What speed bumps or pot holes should I look for before/during/after doing this?

Hi,

i have a visualforce page and i am using Apex:InputFile  for uploading Image file(this image file will be stored in notes and attachments under a custom object record)   .

i have a pageblock table where the user can manualy add records . once the user click submit button, the image file name will be stored in a particular field for all these records.

Now i want to upload Multiple Images  and relate each image name with their respective records in the table.

Can someone help me with this scenario? ?  as far as i know apex:inputfile allows uploading of only one file and multiple files at a time is not possible.

 

Table:

111---------image1
144--------image1 
222-----------------image2
333-------------image3


 

I'm using SOSL to search Subject,Status and Activitydate on Task object . The search works for only Subject but when i enter status say 'In progress' it is not displaying.

How can i make search run on Subject,Status or by Activitydate as well ? Also,how do i make search work for enhance list created instead of rendering values down ? PLease help .


  <apex:page standardController="Task" extensions="TaskSearchController">
    <apex:enhancedlist type="Activity" height="800" rowsPerPage="50" customizable="False"/>

      <apex:form id="searchForm">
      <apex:PageBlock mode="edit">       
      <apex:pageblockSection id="searchBlockSection">
       <apex:pageBlockSectionItem id="searchBlockSectionItem">
        <apex:outputLabel >Keyword</apex:outputLabel>
            <apex:panelGroup >
                <apex:inputtext id="searchTextBox" value="{!searchText}">

                </apex:inputtext>
                <apex:commandButton Id="btnSearch" action="{!Search}" rerender="renderBlock" status="status" title="Search" value="Search">                    </apex:commandButton>
            </apex:panelGroup>
        </apex:pageBlockSectionItem>
    </apex:pageblockSection>
    <apex:actionStatus id="status" startText="Searching... please wait..."/>       
    <apex:pageBlocksection id="renderBlock" >
        <apex:pageblocktable value="{!SearchResults}" var="o" rendered="{!NOT(ISNULL(SearchResults))}">
            <apex:outputLink value="/{!o.Id}">{!o.Subject}</apex:outputLink>
            <apex:column value="{!o.Subject}"/>

        </apex:pageblocktable>      
    </apex:pageBlocksection>
   </apex:pageblock>
  </apex:form>
   </apex:page>


    // Apex class


     public class TaskSearchController
    {
       public apexpages.standardController controller{get;set;}
       public Task l;
       public List<Task> searchResults {get; set; }

      public string searchText
      {
       get
       {
         if (searchText==null) searchText = '';
         return searchText;
       }
      set;
       }

     public TaskSearchController(ApexPages.StandardController controller)
     {
        this.controller = controller;
        this.l = (Task) controller.getRecord();
      }

    public PageReference search()
    {
      if(SearchResults == null)
      {
        SearchResults = new List<Task>();
      }
     else
     {
        SearchResults.Clear();
     }

     String qry = 'Select Id, Subject,Status from Task where Subject like \'%'+searchText+'%\' Order By Subject,Status';
  // System.debug(qry);
    SearchResults = Database.query(qry);
   // System.debug(SearchResults);
   return null;
    }
   }
Hi All,

I have web tab that points to Opportunities standard object. The URL is http:///006/o?isdtp=vw, and I expected this to mimic Opportunities standard tab. And the page that opens up looks pretty much the same. But, neither New nor New Opportunity buttons don't work. Nothing happens when I click on them. Does anyone know why? Note: creating VF tab that points to Opportunities object works fine with regard to the same buttons. Thank you!
Hi everyone,
      Can anyone give me the material for visualforce
Thanks in advace,
Karthick
I am trying to create a custom delete button on an objectA which deletes the particular record only if the value in fieldA matches the Role of the logged in user. If it does not match it needs to throw an error. I was trying to use 'OnClick javascript". Can anyone help me wit the code? Thanks!
Hi ,
I have a Contact field on a custom object which has a look up filter to an account (account lookup field on the same custom object). When I update the contact to another contact (belonging to the same account) , I get a message that "Contact is no longer valid with your selections" although the contact does match the filter criteria. It saves successfully though.

This message also occurs when the previous contact is reselected.

Is this a known Salesforce bug?

Thanks in advance!


  • July 08, 2014
  • Like
  • 0
I can't see system log. Can anybody know about this?

Hi,

I have a trigger for which i have written a test class for it , it covers 72% , i want to increase more than it , not able to figure out how to increase,


My Trigger

 

/**
**
**/
trigger AF_processETBouncebacks on et4ae5__IndividualEmailResult__c (after insert) {

   Map<String,String> aeMap = new Map<String,String>();
   List<Case> casesToInsert = new List<Case>();
   List<Task> tasksToInsert = new List<Task>();
   List<et4ae5__IndividualEmailResult__c> bouncedEmails = new List<et4ae5__IndividualEmailResult__c>();
   Map<String,String> acEmailMap = new Map<String,String>();
        
   for (et4ae5__IndividualEmailResult__c bouncedEmail: Trigger.New) {
  
      if (bouncedEmail.et4ae5__HardBounce__c) {
           bouncedEmails.add(bouncedEmail);
       }
   }

   if (bouncedEmails.size() > 0) {
     
      for (et4ae5__IndividualEmailResult__c tempList : [Select et4ae5__Contact__r.AccountId from et4ae5__IndividualEmailResult__c Where Id IN :bouncedEmails]){ 
          acEmailMap.put(tempList.Id,tempList.et4ae5__Contact__r.AccountId);
      }
     
      Map<String, RecordType>  caseRecordTypeMap = AF_DealerCRM_Utility.getRecordTypes('Case'); 
      Map<String,Group> dealerCrmQueueMap = AF_DealerCRM_Utility.getDealerCrmQueue();
      aeMap = AF_DealerCRM_Utility.getAE(acEmailMap.values());
     
      for (et4ae5__IndividualEmailResult__c email: bouncedEmails) {
     
          String acId = acEmailMap.get(email.id);
         
          if (aeMap.containsKey(acId)) { 
             Task tsk = new Task();
             tsk.WhoId = email.et4ae5__Contact__c;
             tsk.OwnerId = aeMap.get(acId); 
             tsk.Subject = 'Bounceback Correction';
             tsk.ActivityDate = date.today()+5;
             tsk.CreatedById = System.Label.ExactTarget_Admin;
             tsk.Description = 'There was a bounceback for this Contact. The email send id : ' + email.et4ae5__SendDefinition__c;
             tasksToInsert.add (tsk);
          }
          else {
              // If no Autofinance AE or Additional AE exists, then create a case and assign to Sales Performance Queue.
              Case cs = new Case();
              cs.AccountId = acId;
              cs.Priority = 'Medium';
              cs.Subject = 'No AE found on Account Team';
              cs.Status = 'New';
              cs.Description = 'Please navigate to the contact on this case to re-assign the task owner';
              cs.ContactId = email.et4ae5__Contact__c;
              cs.Case_related_to__c = 'Contact';
              cs.RecordTypeId = caseRecordTypeMap.get('Sales').Id;
              cs.OwnerId = dealerCrmQueueMap.get('Case Mgmt Sales Performance').Id;
              casesToInsert.add(cs);
          }
            
      }    

      /* New Cases for AE that are not found.*/
      if (casesToInsert.size() > 0 ) {
       
         try {
            AF_DealerCRM_DML_Utility.insert_op(casesToInsert); 
         }
         catch(Exception ex) {
            system.debug('Exception while creating Case' + ex.getMessage());
         }    
      }
     
      /* New Tasks to create for bounced emails */
      if (tasksToInsert.size() > 0) {
     
         try {
             AF_DealerCRM_DML_Utility.insert_op(tasksToInsert); 
         }
         catch(Exception ex) {
             system.debug('Exception while creating Tasks for bounced emails : ' + ex.getMessage());
         }    
           
      } 
   }
 
}


My Test class :

@isTest
public class AF_processETBouncebacks{
   
    testMethod static void testProcessBouncebacksTrigger() {
        Test.startTest();
        // Create a few records to test various scenarios
       
       
        contact con = new contact();
        con.LastName ='c';
        insert con;
       
       
        Account acc = new Account();
        acc.Name ='Test';
        insert acc;
     
       
        et4ae5__IndividualEmailResult__c emailresult = new et4ae5__IndividualEmailResult__c();
        emailresult.et4ae5__Contact__c =con.id;
        //emailresult.et4ae5__Contact__r.AccountId=acc.id;
        emailresult.et4ae5__DateBounced__c =date.today();
        emailresult.et4ae5__HardBounce__c = true;
        emailresult.et4ae5__Opened__c = true;
        insert emailresult;
       
       
         Task tsk = new Task();
         tsk.WhoId =con.id;
         //tsk.OwnerId = aeMap.get(acId); 
         tsk.Subject = 'Bounceback Correction';
         tsk.ActivityDate = date.today()+5;
         //tsk.CreatedById = System.Label.ExactTarget_Admin;
         tsk.Description = 'There was a bounceback for this Contact. The email send id : ';
         insert tsk;
        
        
        
        
         Case cs = new Case();
         cs.AccountId = acc.Id;
         cs.Priority = 'Medium';
         cs.Subject = 'No AE found on Account Team';
         cs.Status = 'New';
         cs.Description = 'Please navigate to the contact on this case to re-assign the task owner';
         cs.ContactId = con.Id;
         cs.Case_related_to__c = 'Contact';
         insert cs;
        
        
        

        Test.stopTest();

        //Task createdTasks = [Select Id,WhoId ,OwnerId ,Subject ,ActivityDate,Description  from Task Where WhoId IN:emailresult];
        // verify if target tasks etc are created successfully
      //System.assert(tsk);

    }
  

}


i also want to add system.assert statement to my test class , can that increase my coverage


kindly help me on this class

Thanks in Advnce 

Hi,

The usage numbers my company is seeing from the downloadable Force.com Sites Usage Reporting app (found here: https://appexchange.salesforce.com/listingDetail?listingId=a0N30000001SUEwEAO) are significantly higher (100,000 - 300,000 more page views per month) than those numbers reported by Google Analytics.  Has anyone else experienced this?  I'm exploring the Google Analytics side to determine if we have any automated tasks running that aren't getting counted as page views in Google Analytics but are counted by Salesforce but am out of my depth.  Any thoughts or suggestions would be helpful.

Thanks!
Hi all,

Can some one please help me to answer this question - 

In Master-Detail relationship scenario the fields of the parent object need to
be displayed in the related list. How will a developer design this?
a. Cross-object formula field
b. Workflow rule
c. Validation rule
d. Assignment rule

Thanks in advance.

Regards,
Manu
Hi All,

    I have a requriment,  once the account is Created, the owner of account must changed to the Groupe.
Criteria is based on stated the state of account, Groupe should be assigned.(North, South, East, West) Groupe.

Please, Help me.. How to do ? Is it possible with Configration ? Or I have to go to Workflow or Trigger ?

Thanks in Advance :)
Cheer,
Baba
Hi all,

I experienced this problem recently when I tried deploying a list of Custom labels along with their translations from sandbox to production.

I have created a change set in sandbox including all the Custom lables and uploaded it to the Production environment.
Then I have validated and deployed it in Production environment from Inbound change sets. All the other changes are getting reflected in production but the translations.

For each of the custom labels I have added mulitple translations which are not deployed in the production. The weird part is I already deployed some of the custom labels from sandbox to production for the first time. It went well.

Now the deployment is not updating the translations in the custom labels. Anyone here experienced the same? BTW i'm not using Force.com IDE.
Please suggest a solution for this.

Thanks in advance
<apex:page controller="ColourTableFormat" tabStyle="Account">
<apex:form >
<apex:outputPanel id="out">
<apex:selectCheckboxes value="{!colour}" title ="choose a colour"/>
<apex:pageBlock Title="Colour">
<apex:pageBlockSection title="Colour Summary">
<apex:pageBlockTable value="{!colour}" var="C" columns="3">
<apex:column headerValue="COLOUR"/ >
<apex:selectList value="{!colour}"  Multiselect="false" size="1"/ >
<apex:selectOptions value="{!items}" ></apex:selectOptions>
<apex:actionStatus id="status" startText="testing..."></apex:actionStatus>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>






public class ColourTableFormat
{
   
public boolean checkbox;
public string colour {set;get;}
public integer wavelength {set;get;}
public string description {set;get;}
public list<selectOption> options {get;set;}


public ColourTableFormat()
{
options = new list<selectOption>() ;
checkbox = false;
colour = ' ';
description = ' ';

}
public list<selectOption> getitems()
{
options.add(new selectOption('','----None-----'));
options.add(new selectOption('red','red'));
options.add(new selectOption('green','green'));
options.add(new selectOption('yellow','yellow'));
options.add(new selectOption('','----None-----'));
options.add(new selectOption('15','15'));
options.add(new selectOption('20','20'));
options.add(new selectOption('25','25'));
options.add(new selectOption('','----None-----'));
options.add(new selectOption('Red is the color next to orange at the end of the visible spectrum','Red is the color next to orange at the end of the visible spectrum'));
options.add(new selectOption('Green is the color of nature fertility life','Green is the color of nature fertility life'));
options.add(new selectOption('The color yellow is the color of the mind and the intellect','The color yellow is the color of the mind and the intellect'));

return options;

}
public string getcolour()

{
return colour;
}
public void setcolour()
{
this.colour=colour;
}
}
The chatter api to run a query for Ex "https://na1.salesforce.com/services/data/v20.0/query/?q=SELECT+name+from+Account" does not work now. It was working 7 days before.
Can someone help me why this does not work now...is there any version change recently?

Hi,

I was wondering if its possible for a report to only look at one specific record rather than a group of records? The report currently loos at 6 'fixtures' when i only want it to look at one. This works if I create the report inside the actual record however i want it to appear on the dashboard. 

Many thanks.
Hi All,

Is this possible the method SetPassword on formula field or workflow formula?

I want to change the password whenever user has created, this i want to acheive with out trigger/batch, is this possible?

Thanks in Advance!!
I am trying to create custom object email template in salesorce,but it is not working.I tried merging custom object in email template it is worked the custom field is merged but it is not visible when email is sent.In salesforce, we require settargetobjectid to send mail's and get the context but it is only get the id of contact,lead and user not custom object.can any one please tell how to get the email template work in salesforce?

Please find my Email Template below with custom object 'Conference_Details_video__c':

Subject : {!User.Name} Event
When: {!Today}

VMR number: {!Conference_Details_video__c.VMR__c}

MEAURL: {!Conference_Details_video__c.MEAURL__c}

This Video Conference is scheduled from Salesforce App for Polycom RealPresence® CloudAXIS™
Hello,

Does anyone know if it's possible to submit a record for approval using a custom button?  I would like to create three different approval processes where each approval process would have it's own custom submission button.

Each approval process would have the same entry criteria. Depending on which approval button the users clicks that record would be submitted for approval using the approval process tied to that particular custom approval button.

So instead of having just a single "Submit for Approval" button there would be three different buttons that the users could click to kickoff an approval process.

Any feedback would be greatly appreciated.

Thank you!
  • September 03, 2014
  • Like
  • 1
Hello,
    I am validating the deoployment (using eclipse) to production. However getting error. Please help.

 Code Validation Error


Regards,
Saurabh
Hi All,

I am trying to implement salesforce to outlook integeration. I have setup outlook configuration where in we can add case to an email.

My question is there any way by which we can add email to existing cases through salesforce to outlook configuration side panel.

Thanks in advance.
How to integrate salesforce chatter with dnn
We want to make data category mandatory (at least one)  in order to publish knwoledge article. I understand this is not possible from standard validation rule. can we accomplish this by trigger? Any help is greatly appreciated.

Hello

I've register as developer here: https://developer.salesforce.com/

Now I want to generate WSDL file and download it. I followed this instruction: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_quickstart_steps_generate_wsdl.htm

But when I go to Develop | API I see next picture: https://www.dropbox.com/s/udpap8f648adi5c/salesforce.jpg?dl=0

Could you explain what I did wrong? How can I get WSDL?

Hello
I am using Data Loadr for the first time to update a small number of records on a Custom object in my Sandbox.  

Initialization is successful but the upsert fails due to a trigger issue I think as i get the following error?

IncidentTrigger_After: execution of AfterInsert

caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [LastName]: [LastName]

Trigger.IncidentTrigger_After: line 40, column 1



Can anyone help as to what the issue might be?

 I thought about making the trigger inactive in the sandbox to see if this would help, but I cannot seem to do this.

Thanks
Sonya 
In case someone has the same problem for the future I do believe this is a bug and this is the workaround that I found. 

I had a button that performed a search in a standalone visualforce page and it was working without any issues. From the button I could see it working and refreshing the pageblock and calling the function in the debug logs. I then decided to embed it in a visualforce tab panel and it stopped working - page block would refresh but no reference to my function/system debugs in the debug logs. 
But I found a workaround that works:

My initial button inside the tab panel/tab:
<apex:commandButton styleClass="search-block-button" value="Search" action="{!SearchAccountProspect}" rerender="TablePanelProspect" status="TableUpdateStatus" />

Workaround - instead of using the action and calling the function there you can use the onclick and call a action function inside Visualforce:

<apex:commandButton styleClass="search-block-button" value="Search Prospects" onclick="SearchProspect(); return false;" rerender="TablePanelProspect" status="TableUpdateStatus" />

<apex:actionFunction name="SearchProspect" action="{!SearchAccountProspect}" rerender="TablePanel" status="TableUpdateStatus"/>
(placed just after the apex:form tab - outside the apex:TabPanel tag.
We have requirement to greyout/disable all the dates greater than 5 days in the calender.  As this is not possible in salesforce out-of-box functionality, I am looking for ways to achieve this.  Can anyone help on this?

I have to write a Rest service for retreiving data from salesforce object ??

i have 6-7 filters for that..
which i have to send as parameter ..
Data will be ... name of users... 10-15..
other records details..
what should i use for this Get ot Post ????
please suggest... with advantages of using the one..

  • May 08, 2014
  • Like
  • 1
Metadata API v29.

When using metadata retrieve() call to retrieve specificFiles e.g. MyClass.cls, MyPage.page or Contact.object system returns correct CreatedDate & LastModifiedDate for code files like MyClass.cls or MyPage.page but not for objects like Contact.object.

retrieve() call for Contact.object (and other objects) always returns current Date/Time instead of the real CreatedDate and LastModifiedDate.
So if I issue retrieve() call for Contact.object twice in a row I will get two different Create and LastModified dates.

Does anyone now a workaround for this?
  • March 06, 2014
  • Like
  • 1
I work in a Salesforce consultant team and often, when we need to sync objects with an external service, our developpers run in some data consistency problem, governor limit issue and all kind of pretty hard to resolved. 

I wrote an article this morning one way one we solve a customer need, I guess it can be of some help to those of you having simmilar issues : 
Hi all! We've launched some new features here on the forums today - thanks to you all for your feedback on the new site! Here's today's update:
  • New "Start a Discussion"  button to make it easier for you to start a new thread (we still strongly encourage you to search the existing topics before you post though as it's very likely your topic has been addressed before!)
  • Infinite scroll starts higher up on the page to provide a smoother experience
  • Added a "Continue Reading" link on each discussion card
  • Fixed a bug affecting the display of dates on some profile pages
  • Fixes to how notifications are sent when you like or reply to posts
Our development team is actively working on site enhancements, so please keep the feedback coming!! Let us know what you think of the site and what you'd like to see.

Best,
April
Hi,
I have created one user with System Administrator profile and when i login with that user I can able to use one option (for eg: Create case).
But I am unable to use that create case option with the new user login which had been created with the new custom profile.
Is there any thing need to check in custom profile? Please suggest me.

Thanks in Advance.
  • December 27, 2013
  • Like
  • 1
When I add the "My Email to Salesforce" address to the "additional emails" field of an email alert the email does not get added to the activity history.
I am adding the correct address and the correct record Id of the record to which the email needs to be added.
When I send the email manually through an external email client, it works perfect. But the same is not working through an email alert.

I have 2 sand boxes. It works on one but not on the other. Can anyone throw light on this?

Today we’re excited to announce the new Salesforce Developers Discussion Forums. We’ve listened to your feedback on how we can improve the forums.  With Chatter Answers, built on the Salesforce1 Platform, we were able to implement an entirely new experience, integrated with the rest of the Salesforce Developers site.  By the way, it’s also mobile-friendly.

We’ve migrated all the existing data, including user accounts. You can use the same Salesforce account you’ve always used to login right away.  You’ll also have a great new user profile page that will highlight your community activity.  Kudos have been replaced by “liking” a post instead and you’ll now be able to filter solved vs unsolved posts.

This is, of course, only the beginning  and because it’s built on the Salesforce1 Platform, we’re going to be able to bring you more features faster than ever before.  Be sure to share any feedback, ideas, or questions you have on this forum post.

Hats off to our development team who has been working tirelessly over the past few months to bring this new experience to our community. And thanks to each of you for helping to build one of the most vibrant and collaborative developer communities ever.
 

As a newbie with Chatter I had real problems figuring out the process to retrieve data so hopefully the following will help any other newbies trying to figure it out. Using the Developer Edition:

 

 

1. You will need an https domain where you will run your app which will make a request to your Chatter App
2. You will need to register a new sub domain within the Setup. I think it was under Domains. So you will have something like mydomain-dev-ed.my.salesforce.com

3. Create a Connected App (Create/Apps)
4. The Start URL will be the sub domain you created
5. Select the checkbox for Enable OAuth Settings
6. The callback url will be a path to your https domain on your server (ie https path/to/results.aspx
7. Put all the selected OAuth Scopes over to the right
8. Save

 

_____________________________________________________________________

_____________________________________________________________________

 

In the left side navigation you will see there is Manage Apps and Create/Apps

You will find info about your Connected App in both those locations.
You will need the Consumer Key, Consumer Secret and Callback Url (or redirect url)

You will now create two .net files which will reside on your server:

 

 

1. default.aspx
2. results.aspx

 

_______________________________________________________________________

 

The default.aspx will make the initial call to salesforce which will return a javascript string.
You will need to extract the relevant content from the string to use, which in turn will open a login page.

Once you have logged in, additional values will be passed back to your app.

 

______________________________________________________________________

______________________________________________________________________

 

In your default.aspx

 

 

 

string clientid = "this is the Consumer Key ";
string redirecturl = "https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=" + clientid + "&redirect_uri=" + redirecturl ;
var webRequest = (HttpWebRequest)WebRequest.Create(uri);
webRequest.Method = "POST";
[Inside a try/catch put the following]
WebClient webClient = new WebClient();
webClient.Encoding = Encoding.UTF8;
result = webClient.DownloadString(uri);

string returnedString = result;

[The result is the string returned which you will need to extract the url contained within the string]
At this point you need to create a ClientScript which, when called, will load the login page.

String csname2 = "myscript";
Type cstype = this.GetType();
string jsScript = "<script>window.location.href ='" + Your_Extracted_Url + "'</script>";
ClientScriptManager cs = Page.ClientScript;
cs.RegisterClientScriptBlock(cstype, csname2, jsScript);

 

 

If you save the default.aspx, compiled your project and uploaded to your server then ran it, you would get the login page.

Something like:

 

https://login.salesforce.com/?ec=302&startURL=%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3Dl86Hcy6qEKtWNqzXVErZDlmcRQs0D_HBE55MLVuP3x8t5wXkyHYyrVx2Xb5JoWzyVOJrnTqMMaWy_Sfomv.j1xklSQ67NPiEbdAN9Vn15MXpcuc7Tn4&sdtd=1


Now when you submit the login page, it is effectively going to your callback page you designated earlier, so now you have to add code to this file to retrieve the required data.

Result.aspx

[you can add your own try/catch and conditions]

 

string clientid = "same as previous";
string clientsecret = "your client secret";
string redirecturl = "same as previous";

string uri = "https://login.database.com/services/oauth2/token?grant_type=authorization_code&client_id=" + clientid + "&client_secret=" + clientsecret + "&redirect_uri=" + redirecturl + "&code=" + res + "&format=json";


var webRequest = (HttpWebRequest)WebRequest.Create(uri);
webRequest.Method = "POST";


if (webRequest.HaveResponse && response != null)
{
using (var reader = new StreamReader(response.GetResponseStream()))
{
        string result = reader.ReadToEnd();
        JavaScriptSerializer ser = new JavaScriptSerializer();
        Dictionary<string,object> dict = ser.Deserialize<Dictionary<string, object>>(result);
        int dCount = 0;


       foreach (string strVal in dict.Values)
       {
         if (dCount == 6)
             {
                    string chatterApiUri = "https://SubdomainYouCreated.my.salesforce.com/services/data/v23.0/chatter/users/me";
                   var webRequestlogin = (HttpWebRequest)WebRequest.Create(chatterApiUri);
                  webRequestlogin.Headers.Add("Authorization", "OAuth "+ sToken);
                 webRequestlogin.Method = "GET";

                    using (var aresponse = webRequestlogin.GetResponse() as HttpWebResponse)
                    {
                                if (webRequestlogin.HaveResponse && response != null)
                               {
                                        using (var areader = new StreamReader(aresponse.GetResponseStream()))
                                       {
                                              string aresult = areader.ReadToEnd();
                                              lblresult.Text += "HERE IS YOUR RESULT " + aresult;
                                       }
                               }
                   }
 
       }
    }
  }
}

 

 

 

 

Your page on your server should display something like the following:

{"address":{"state":null,"country":"GB","street":null,"city":null,"zip":"EH3 5RT"},"email".......etc

 

 

It's a start but hopefully this will help because the documentation is shoddy.

  • October 03, 2013
  • Like
  • 1

As many of you have discovered, our developer community is awesome. The wealth of knowledge here is phenomenal. This is an all volunteer community and people who take the time to help and post answers do so totally on their own initiative. With that said when someone provides the right answer to your question please take the time to mark their answer as the accepted solution. Also give them a kudos if they've really gone the extra mile to help out. Show some love ;)