• sivaext
  • NEWBIE
  • 363 Points
  • Member since 2012


  • Chatter
    Feed
  • 12
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 37
    Questions
  • 178
    Replies

How do I set selectoption value dynamically based on query results?

 

I have a single select picklist on my VF page with list values 1,2,3,4,5 and I would like to use this selectlist within datatable to read/write records to database. I am able to write the data to table but when I want to read the data the selectoption is not showing the stored value automatically[still showing the list to select one option]. For sure I must be missing something silly so I would like to request for an example with both controller and VF page code.

 

Thank you

Is it possible to have a picklist with values that are not selectable and sub values that are?  I've been searching the board and haven't seen an example of what I'm trying to do.

 

Example of picklist values:

 

Header1 (not a selectable value)

    Child1a

    Child1b

Header2 (not a selectable value)

    Child2a

    Child2b

 

thanks in advance,

 

Tim

 

 

 

Hi All, I'm new to apex and I'm having trouble writing a test classes. :( How can I go about getting at least a 80% code coverage?

 

trigger PPM_CreateEquipmentDetailsRecord on PPM_Project__c (after update) {
    List <PPM_Equipment_Details_History__c> RecToInsert = new List <PPM_Equipment_Details_History__c> ();
    for (PPM_Project__c PPMP : Trigger.new) {
        PPM_Project__c beforeUpdate = System.Trigger.oldMap.get(PPMP.Id);
        if (beforeUpdate.of_Changes_to_Equipment_Details__c != PPMP.of_Changes_to_Equipment_Details__c) {
            PPM_Equipment_Details_History__c PPMBDH = new PPM_Equipment_Details_History__c ();
            PPMBDH.Equipment_Details_Old_Value__c = beforeUpdate.Equipment_Details__c;
            PPMBDH.Equipment_Details_New_Value__c = PPMP.Equipment_Details__c;
            PPMBDH.Project__c = PPMP.Id;
            RecToInsert.add(PPMBDH);
        }
    }
    try {
        insert RecToInsert; 
    } catch (system.Dmlexception e) {
        system.debug (e);
    }
}

 

Hi, I am just learning how to read/write Apex, so I'm sure this is a really basic problem, but I would really appreciate any help!

 

I created a trigger that will create a new Case record when an Opportunity meets the following criteria (Type = 'Maintenance Renewal' & Probability = 100).  I'm running into two issues with the below code:

1) the trigger is working, except it is creating 2 identical Case records for each Opp which meets the above criteria

2) I can't figure out how to populate the 2 necessary lookup fields on the Case: Owner (which needs to be the Maintenance Renewal Queue) & Contact (which needs to be the Opportunity Owner)

 

Thank you in advance to anyone who can help!!

 

Here is the trigger:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
trigger createNewCase on Opportunity (after update) 
{
    List<Case> listCase = new List<Case>();
    for(Opportunity o : trigger.new)
    {
        if(o.Type == 'Maintenance Renewal' && o.Probability == 100)
        {
          //here Opportunity__c is lookup to Opportunity record for which new record is created
          listCase.add(new Case(Opportunity__c = o.id, 
          Subject = o.Name,
          Origin = 'Email-Renewals',
          Priority = 'Medium',
          Status = 'New'));
          
        }
    }
    
    if(listCase.size() > 0)
    {
        insert listCase;
    }
}

I would like to get a list of all of the products in the org so that I can work with it.  I have tried:

 list<product2> pl = [select name, id from Product2];

but I am only getting a few products not all of them.   Any idea how I can do this?

Looking to use a VF page to display as a select list all profiles on the org and allow them to be selected into a custom object.

The display of profile all works fine, however when i try to add the value:

jProfile, it returns nothing.

selectedProfilesit returns Null.

 

Any suggestions as to where i am going wrong? Thanks

 

VF

    <apex:pageBlock id="block">
    <apex:pageMessages />          
        <apex:pageBlockSection title="Add Rule" id="section1">
<apex:pageBlockSectionItem id="selProfile"> <apex:outputLabel value="Profile"/> <apex:selectList value="{!selectedProfiles}" size="1" id="ProfilesSelect"> <apex:selectOptions value="{!Profiles}"/> </apex:selectList> </apex:pageBlockSectionItem>

        <apex:commandButton value="Create New Rule" action="{!addRule}" reRender="block" immediate="true">
        <apex:param name="jmProfile" value="{!selectedProfiles}" assignTo="{!jProfile}"/>
        </apex:commandButton>

 Controller

    private List<SelectOption> Profiles;
    
    public List<String> selectedProfiles {get; set;}
    public String jProfile {get;set;} 
    
    public List<SelectOption> getProfiles() {
      Profiles = new List<SelectOption>();
      Profiles.add(new SelectOption('None', 'None'));
      for (Profile rt : [Select Id, Name 
                            From Profile 
                            Order By Name ASC]) {                 
        Profiles.add(new SelectOption(rt.Name, rt.Name));
      }
      return Profiles;
    }

 

  • December 22, 2012
  • Like
  • 0

I have a problem with a very simple trigger. The error I am getting is:

 

 UpdateownertoCovanceContact: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.UpdateownertoCovanceContact: line 7, column 1

 

When i change to "before update", I get this error:

 

Apex trigger UpdateownertoCovanceContact caused an unexpected exception, contact your administrator: UpdateownertoCovanceContact: data changed by trigger for field Owner ID: owner cannot be blank

 

All I am trying to do is have the Owner be replaced with the Covance Contact, (which is just a lookup field to the user record) upon save. This is such a simple trigger but i just can't figure it out. Thanks!

 

Here is the code:

 

trigger UpdateownertoCovanceContact on Contact_Team__c (after insert, after update) {
for (Contact_Team__c ct: trigger.new) {

if (ct.Rship_to_Covance_Contact__c!='neutral') {


ct.Ownerid= ct.Covance_Contact__r.Id ;
}
}
}

 

 

Iam having 2 custom objects, 1)Digitalfactory 2)Stage.both are in lookup relation.stage name and stage creation date,are 2 fields in stage object. and SALESREADYDATE is the field in Devfactory (object).

requirement:- i need to write a trigger,when ever the stage name=closed ,then date of creation should come to salesready date (field)in devfactory(object)

I have a field on Opportunity that calculates number of forecast days 30,60,90 based on todays date. The formula is as below

If( Year(CloseDate) = Year(Today())+1,

IF(MONTH(CloseDate) = MONTH(Today()) , '30 Day',

IF(MONTH(CloseDate) = MONTH(Today()) + 1, '60 Day',

IF(MONTH(CloseDate) = MONTH(Today()) + 2, '90 Day','No'))), 

'No')

 

This formula doesnt work if close data is 02/01/2013 .The answer should be '90 Day' but it is 'No'.Can anyone help with the formula.

  • December 13, 2012
  • Like
  • 0

Hi , 

 

Can some one help me out how to make a Schedule task which sends email:

 

Requirement:

 

I have records which needs Approval from a dynamic list of Approvers. So i 

created a Junction Object which holds the record and user look up[for custom object] .. The Juction object has record look up and custom Object Lookup which has status field pending and Approved ..

 

I need to send an email to all the users whose status is pending as daily reminders .. 

 

can some one help me to achieve this task.

 

how to I send Emails to all pending records in Junction object..

daily at 9:00 AM 

 

 

 

 

 

 

Hello, 

 

I have a custom object that is a child to the opportunity object. There is a trigger on that custom object that updates a field on the opportunity if a checkbox is marked as true. 

 

The trigger appears to be working when I do manual testing, but the test class system.asserts are failing. 

 

I can't figure out why the trigger is not functioning properly in the testClass, but works correctly in the UI. 

 

Any help would be greatly appreciated!!! 

 

Trigger

trigger UpdateOpptyLeadBusCon on Business_Consultant__c (before update, before insert, before delete) {

//Get the Business Consultant & Opportunity records
set<id> opportunitiesid = new set<id>();

//Set trigger.new or trigger.old depending on if isUpdate / isInsert / isDelete
if(trigger.isUpdate || trigger.isInsert){
    for(Business_Consultant__c buscon: Trigger.New) {
        opportunitiesid.add(buscon.Opportunity__c);
        }
    }else{
    for(Business_Consultant__c buscon: Trigger.Old) {
        opportunitiesid.add(buscon.Opportunity__c);
        }
}

//Create the lists of opportunities        
    List<Opportunity> updatelst = new List<Opportunity>();
    List<Opportunity> lstopp =[select id, Lead_bus_consultant__c from Opportunity where id IN:opportunitiesid];

 
//If isInsert && lead_consultant__c = True, then set the opportunity lead_bus_consultant__c
if(trigger.isInsert){
    for(Business_Consultant__c buscon:Trigger.New) {
        if(buscon.Lead_Consultant__c == TRUE) {
            for(Opportunity opp:lstopp) {
                 if(opp.id == buscon.opportunity__c) {
                     opp.Lead_bus_consultant__c = buscon.consultant__c;
                      updatelst.add(opp);
                 }
            }
        }
    }
}

//If isUpdate check to see if it is changed
if(trigger.isUpdate){
    
    for(Business_Consultant__c buscon:Trigger.New){
    Business_Consultant__c oldBusCon = Trigger.oldMap.get(buscon.Id);
    //If the checkbox has changed position and is no longer true, clear out the opportunity.lead_bus_consultant__c field
    if(Trigger.isUpdate && buscon.Lead_Consultant__c != oldBusCon.Lead_Consultant__c  && buscon.Lead_Consultant__c != TRUE){
        for(Opportunity opp:lstopp){
            if(opp.id == buscon.opportunity__c){
                opp.Lead_bus_consultant__c = null;
                    updatelst.add(opp);
            }
        } 
    }else{
    //Otherwise if the checkbox is checked, set the opportunity.lead_bus_consultant__c field as the consultant from the connector
    if(buscon.Lead_Consultant__c == TRUE) {
 
        for(Opportunity opp:lstopp) {
                 if(opp.id == buscon.opportunity__c) {
 
                     opp.Lead_bus_consultant__c = buscon.consultant__c;
                      updatelst.add(opp);
                }
        }
    }
    }
    }
} 
//If isDelete set the opportunity.lead_bus_consultant__c to null 
else {
if(trigger.isDelete){

    for(Business_Consultant__c buscon:Trigger.Old){
        Business_Consultant__c oldBusCon = Trigger.oldMap.get(buscon.Id);
        if(Trigger.isDelete && buscon.Lead_Consultant__c == TRUE){
            for(Opportunity opp:lstopp){
                if(opp.id == buscon.opportunity__c){
                    opp.Lead_bus_consultant__c = null;
                        updatelst.add(opp);
                }
            } 
        } 
    } 
} 
}
//Update the list of opportnities
update updatelst;
}

 

 

 

Test Class

public class testUpdateOpptyLeadBusCon {
    static testMethod void testUpdateOpptyLeadBusCon() {

//Create test profile 
Profile p = [select id from profile where name='System Administrator'];

//Create Users 
    User User1 = new User(alias = 'u1', email='u1@testorg.com',
      emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
      localesidkey='en_US', profileid = p.Id, country='United States',
      timezonesidkey='America/Los_Angeles', username='u1@testorg.com');
    insert User1;

    User User2 = new User(alias = 'u2', email='u2@testorg.com',
      emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
      localesidkey='en_US', profileid = p.Id, country='United States',
      timezonesidkey='America/Los_Angeles', username='u2@testorg.com');
    insert User2;

//Create Q-Scan Opportunity 
    Opportunity op = new Opportunity (owner=User1, name='Q-Scan Opportunity', Type='Q-Scan', stageName='Targeted Accounts', closeDate=system.today(), LeadSource='Vision');
    insert op;

//Test isInsert portion of code
//Create Business_Consultant__c 'BC1' (lead = false)
    Business_Consultant__c BC1 = new Business_Consultant__c(Consultant__c = User1.id, Opportunity__c = op.id, Lead_Consultant__c = FALSE); 
    insert BC1; 

//Create Business_Consultant__c 'BC2' (lead = true)
    Business_Consultant__c BC2 = new Business_Consultant__c(Consultant__c = User2.id, Opportunity__c = op.id, Lead_Consultant__c = TRUE); 
    insert BC2; 

    //Test that opportunity.Lead_bus_Consultant__c = User2
        //THIS FAILS
System.assertEquals(User2.id , op.Lead_Bus_Consultant__c); //Test isUpdate portion of code //Uncheck the lead designation on BC2 BC2.Lead_Consultant__c = False; update BC2; //Test that lead business consultant = null system.assertEquals(op.Lead_Bus_Consultant__c, null); //Set Lead_Bus_Consultant=TRUE on BC1 BC1.Lead_Consultant__c = True; update BC1; //Test that lead business consultant = User1 //THIS FAILS
system.assertEquals(op.Lead_Bus_Consultant__c, User1.id); //Delete BC1 delete BC1; //Test that lead business consultant = null system.assertEquals(op.Lead_Bus_Consultant__c, null); } }

 

 

Hi,

   Am updating account object through data loader facing an error please help me

 

form433fupdate: execution of AfterUpdate

caused by: System.ListException: Duplicate id in list: a1B30000001oZDwEAM

Trigger.form433fupdate: line 34, column 1

 

 

trigger form433fupdate on Account (after update)
{
set<id> aset=new set<id>();
for(account a:trigger.new)
{
aset.add(a.id);
}
list<form433f__c> flist=new list<form433f__c>();
for(account a1:trigger.new)
{
for(form433f__c f:[select id,Scell__c,Shome__c,Swork__c,Ssecurity_No__c,E_Sbirthdate__c,Spouse_FullName__c,cell__c,Security_No__c,E_Birth__c,Home__c,work__c,Account__c,name,Personmailingcity__c,Personmailingpostalcode__c,Personmailingstate__c,Personmailingstreet__c from form433f__c where account__c in:aset])
{
f.name=a1.name;
f.county_of_Residence__c=a1.Personmailingcountry;
f.Personmailingcity__c=a1.Personmailingcity;
f.Personmailingpostalcode__c=a1.Personmailingpostalcode;
f.Personmailingstate__c=a1.Personmailingstate;
f.Personmailingstreet__c=a1.Personmailingstreet;
f.cell__c=a1.PersonMobilePhone;
f.Home__c =a1.PersonHomePhone;
f.work__c =a1.PersonOtherPhone;
f.Security_No__c =a1.SSN1__c;
f.E_Birth__c =a1.PersonBirthdate;
f.Ssecurity_No__c =a1.Spouse_SSN1__c;
f.E_Sbirthdate__c =a1.Spouse_Birthdate__c;
f.Spouse_FullName__c=a1.Spouse_FullName__c;
f.Scell__c = a1.Spouse_Cell_Phone__c;
f.Shome__c = a1.Spouse_Home_Phone__c;
f.Swork__c = a1.Spouse_Work_Phone__c;
flist.add(f);
}

}
update flist;
}

We have integrating salesforce with external system. External system have two factor authetication process.
Step1 : We are calling first URL to get challenge. - Working fine.
Step2 : We need to decrypt challenge in step2. We have an issues to decrypt the challenge, the error is "InValid parameter exception, private key must have 16 bytes" .

String challenge = 'NdqeqeqYQVyWaq0jYyB71Odhog==';
blob challenge1 = EncodingUtil.base64Decode(challenge);
String mkey = 'zxvfg12';// client ask to convert into 16bytes but salesforce doesn't support.
blob base64key = EncodingUtil.base64Decode(mpin);
Blob decrypted = Crypto.decryptWithManagedIV('AES128', base64key, challenge1);
system.debug('.......'+decrypted);
String decryptedString = decrypted.toString();
System.debug('......'+decryptedString);

Thanks in Advance.

Siva.
Hi , 

I am trying insert content version using REST API. I have followed all steps mentioned in REST API doc. (https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm#inserting_a_contentversion).

I am able to insert content version in salesforce but when I download, getting error image is damaged.

Please help me how to insert binary data here to test.
--boundary_string Content-Disposition: form-data; name="entity_content"; Content-Type: application/json
{ "ContentDocumentId" : "069D00000000so2", "ReasonForChange" : "Marketing materials updated", "PathOnClient" : "Q1 Sales Brochure.pdf" }
--boundary_string Content-Type: application/octet-stream Content-Disposition: form-data; name="VersionData"; filename="Q1 Sales Brochure.pdf"

Binary data goes here.

--boundary_string--

 
I am using salesforce1 navigation methods but not working.
sforce.one .navigateToSObject(record id);

it is happening only in sandbox but working in production. It happening from past two days only.
  • September 26, 2015
  • Like
  • 0
Hi, 

I got know activities going to archived after 365 days but client need two years data into system. is there anyway to increase limit or stop archiving?

Thanks & Regards
Siva.
Hi , 
Currently we can see no of likes for chatter post.Like is it possible to count no of views for single chatter post?

Regards
Siva.
Hi , 

I have read salesforce documents for single sign on. SSO possible with two approaches

1. SAML 
2. Delegated Authentication.

is single sign on possible with oAuth authentication process? if yes, please help any doc link related to that?

Thanks in Advance.

Regards
Siva.
 
hi,
We have two orgs , one org has enabled DA(delegated authentication). followed below steps to connect from one org to another org
1. Enabled DA
2. Downloaded DA wsdl 
3. enabled single sign on permission to one of the user 
4. added default gateway URL 
5. WSDL parsed into other salesforce org
class:
//Generated by wsdl2apex

public class authenticationSoapSforceCom {
    public class AuthenticateResult {
        public Boolean Authenticated;
        private String[] Authenticated_type_info = new String[]{'Authenticated','urn:authentication.soap.sforce.com',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:authentication.soap.sforce.com','true','false'};
        private String[] field_order_type_info = new String[]{'Authenticated'};
    }
    public class Authenticate {
        public String username;
        public String password;
        public String sourceIp;
        private String[] username_type_info = new String[]{'username','urn:authentication.soap.sforce.com',null,'1','1','false'};
        private String[] password_type_info = new String[]{'password','urn:authentication.soap.sforce.com',null,'1','1','false'};
        private String[] sourceIp_type_info = new String[]{'sourceIp','urn:authentication.soap.sforce.com',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:authentication.soap.sforce.com','true','false'};
        private String[] field_order_type_info = new String[]{'username','password','sourceIp'};
    }
    public class AuthenticationService {
        public String endpoint_x = 'https://test.salesforce.com';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'urn:authentication.soap.sforce.com', 'authenticationSoapSforceCom'};
        public Boolean Authenticate(String username,String password,String sourceIp) {
            authenticationSoapSforceCom.Authenticate request_x = new authenticationSoapSforceCom.Authenticate();
            request_x.username = username;
            request_x.password = password;
            request_x.sourceIp = sourceIp;
            authenticationSoapSforceCom.AuthenticateResult response_x;
            Map<String, authenticationSoapSforceCom.AuthenticateResult> response_map_x = new Map<String, authenticationSoapSforceCom.AuthenticateResult>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'urn:authentication.soap.sforce.com',
              'Authenticate',
              'urn:authentication.soap.sforce.com',
              'AuthenticateResult',
              'authenticationSoapSforceCom.AuthenticateResult'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.Authenticated;
        }
    }
}

testing with developer console

authenticationSoapSforceCom.AuthenticationService   Stub = new authenticationSoapSforceCom.AuthenticationService ();

Stub.Authenticate('test@gmail.com','password','0.0.0.0');

Getting below error:
System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found 'http://www.w3.org/1999/xhtml:html'

Please help to resolve this issue

Thanks 
SIva.
Hi, 

I have created 4 global actions. Global actions are displaying in salesforce1 app but i want some help text for each symbol.

Please let me know if any possible options to add help text.

Thanks & Regards
Siva.
Hi,

We have created VF page and set us default landing page in place of chatter. Once user login , it is mandatory to read content in VF page and agree on that.

User able to click navigation bar and clicking another tab without accepting terms & conditions?

Thanks & Regards
Siva.
Hi , 

I have requirement to build custom reports for sales people performance for current financial years. We have going display data based user selection but each user's data crossing 60,000 + records. As per SOQL query limit for rows is 50000. 

Please help to handle this situation?

Thanks 
SIva.
Hi, 

We have requirement to share one account with multiple users. Please suggest suitable approach to do ?

1. account teams - is account team works fine? is there any limiations use account teams?
2. custom object - admin will upload account code and owner code, write a trigger to share account record?

Thanks 
Hi, 

We have created VF page to show google maps on for different routes. It is working fine yesterday but now we are facing "Over query limit" and "Zero_results". 

please help me

Thanks Advance.
 
Hi , 

I have requirement where similar to Opportunity and opportunity line items. 

I am plan to use only one object with self relationship to achieve this. I knew roll up summary not possible. I am plan to wirte trigger to achieve this. 

Is there any potential drawback to follow this approach? any data base impacts?

Thanks Advance.
Hi,

I have requirement where junction object required but i exceed object limitations
is it possible to achieve M:M relationship without junction object ? is there any potential drawback/impacts on data base architecture?

Requirement is :  One customer have multiple routes , one route have multiple customers 

Please let me know potential impacts if we are using jucntion object ?

Thanks Advance



 
 
Hi All., 

I have created list view on account object. i have given permission to all users to see that list view. 

I have logged into salesforce1 with other user who have admin access but not able to see that list view.

if that user logged through browser, click on that list view , then that list view available in salesforce1

please help me how to get list view in salesforce1 without user clicking thorugh browser.

Thanks in advance



 
Hi, 

I have created one custom object . I have created custom address fields to capture billing address. It is working fine still previous release.

The latest release sf1 , overriding my custom fields, please see below screen shot

  User-added image


  custom fields in my custom object 

   User-added image


Please help me to revert back to my custom fields. i don't want see any sf1 features, 

Please help me
  • September 12, 2014
  • Like
  • 0
Hi,

I have wrote code to upload file using vf page for salesforce1 app. It is working fine if version is greater than or equal to 4.4.3. 

why input file option not working in 4.4.2 or below app in salesforce1 app? is sf1 limitation ?

Thanks in advance.
Hi, 

We have built salesforce hybrid mobile application to one of my customer. It is working both offline and online.  We have problem in syncing data once app closed. 
Currently we have setup "Manual" sync button to sync records between hybrid app and sf server but app should be open while syncing data.

We are plan to write native android background services to sync every 1 hours automatically withoout opening app. 

Can you please suggest process to call native android services using hybrid app (smart store)? 


Thanks in advance.



Hi Guys, 
 
We are using salesforce1 app for mobile app. We have custom object i.e feedback , we are able to create feedback record but not able to add attachments?

How to add attachemnts to custom object records through salesforce1 ?
Hi , 

I have two objects, i.e. monthly plan and monthly plan line items. 

According my requirement , one of the user will submit the monthly plan to respctive manager . 

is it possible to display monthly plan line item related list in approval page ?

Thanks 
Hi , 

We have bought force.com one app license . Standard sharing setting feature is not available . 

is it possible to write apex sharing rule?

Thanks 
Siva.
Hi 

I tam relaoding total page when session expired ,it is working fine.

I am trying to increase performance using other snippet code in mobile sdk pdf but i am not clear couple places.

// Refresh oauth token
cordova.require("salesforce/plugin/oauth").authenticate(
  function(creds) {
   // Reload hidden iframe that points to a blank page to
   // to refresh Visualforce domain cookies
   var iframe = document.getElementById("blankIframeId");
   iframe.src = src;

   // Refresh CSRF cookie
   <provider>.refresh(function() {
     <Retry call for a seamless user experience>;
   });

  },
  function(error) {
    console.log("Refresh failed");
  }
);

can you please explain, what is <provider> here?  i read below lines in some blog , is it true to required case to enable CSRF?

I logged a case for this as I was able to perform CSRF hacks against methods annotated with @RemoteAction and the response is:

This is not enabled by default. You have to contact salesforce to get CSRF protection for Remote Actions turned on.

Can you please give small example for above code?

My code snippet here 

@RemoteAction
        global static List<Account> fetchAccountDetails(String name) {
            //system.assertEquals('fd','jk');
            // where Name LIKE \'%\''+name+'\'%\'
            String qry = 'Select Id,Name,BillingStreet,BillingCity,BillingCountry,BillingState,BillingPostalCode,FloraMobileApp__LGA_Name__c,FloraMobileApp__Stage__c,FloraMobileApp__Total_Order_Arrangements__c,FloraMobileApp__Trial_Arrangements__c,Industry,(Select Salutation,Name,Phone From Account.Contacts) From Account where Name LIKE \'%'+name+'%\' LIMIT 10 ';
            system.debug('search account results'+qry);
            return database.query(qry);
           
        }

function searchAccount(){
             //alert($j('#accountName').val());
            if($j('#accountName').val() != ""){
                //$j.mobile.loading( '', {text: 'Working....',textVisible: true,theme: 'a', html: ""});
                //alert('IN SEARCH METHOD');
                $j.mobile.showPageLoadingMsg("b", "Working....", true);
               
                Visualforce.remoting.Manager.invokeAction(
                    '{!$RemoteAction.MobilePageControllerTest.fetchAccountDetails}',
                    $j('#accountName').val(),                          
                    function(records,event){
                        if (hasSessionExpired(event)) {
                            // Reload will try to redirect to login page, container will intercept
                            // the redirect and refresh the session before reloading the origin page
                            //alert('expired');
                            window.location.reload();
                        }
                        else {
                        //alert(JSON.stringify(event));
                        currentAccountList.length = 0;
                        for(var i = 0; i < records.length; i++) { currentAccountList[records[i].Id] = records[i];} //alert(JSON.stringify(records[i]));
                        $j.mobile.hidePageLoadingMsg();
                       
                        if (event.status) {
                            //alert(JSON.stringify(records));
                            //alert(records[0].Contacts[0].Name);
                            $j('#listMainList').html("");
                            $j.each(records,function() {
                               
                                $j('<li data-theme="c"></li>').attr('id',this.Id).hide().append('<h4>' + this.Name + '</h4>').click(function(e) {
                                   
                                    e.preventDefault();
                                    $j.mobile.showPageLoadingMsg();
                                   
                                    $j('#accId').val(currentAccountList[this.id].Id);
                                    $j('#AccName').html(currentAccountList[this.id].Name);
                                   
                                   
                                    if(currentAccountList[this.id].BillingStreet == undefined){
                                        currentAccountList[this.id].BillingStreet = " ";
                                    }
                                    if(currentAccountList[this.id].BillingCity == undefined){
                                        currentAccountList[this.id].BillingCity = " ";
                                    }
                                    if(currentAccountList[this.id].BillingState == undefined){
                                        currentAccountList[this.id].BillingState = " ";
                                    }
                                    if(currentAccountList[this.id].BillingCountry == undefined){
                                        currentAccountList[this.id].BillingCountry = " ";
                                    }
                                    if(currentAccountList[this.id].BillingPostalCode == undefined){
                                        currentAccountList[this.id].BillingPostalCode = " ";
                                    }
                                   
                                    if(currentAccountList[this.id].FloraMobileApp__LGA_Name__c == undefined){
                                        currentAccountList[this.id].FloraMobileApp__LGA_Name__c = " ";
                                    }
                                    if(currentAccountList[this.id].FloraMobileApp__Stage__c == undefined){
                                        currentAccountList[this.id].FloraMobileApp__Stage__c = " ";
                                    }
                                    //alert('previous');
                                    if(currentAccountList[this.id].FloraMobileApp__Total_Order_Arrangements__c == undefined){
                                        currentAccountList[this.id].FloraMobileApp__Total_Order_Arrangements__c = " ";
                                    }
                                    if(currentAccountList[this.id].FloraMobileApp__Trial_Arrangements__c == undefined){
                                        currentAccountList[this.id].FloraMobileApp__Trial_Arrangements__c = " ";
                                    }
                                    if(currentAccountList[this.id].Industry == undefined){
                                        currentAccountList[this.id].Industry = " ";
                                    }
                                    var addr = " "+currentAccountList[this.id].BillingStreet+" "+currentAccountList[this.id].BillingCity+" "+currentAccountList[this.id].BillingState+" "+currentAccountList[this.id].BillingCountry+" "+currentAccountList[this.id].BillingPostalCode;
                                   
                                    $j('#AccAdd').html(addr);
                                    if(currentAccountList[this.id].Contacts == undefined){
                                        $j('#AccConName').html("");
                                        $j('#AccPhn').html("");
                                    }else{
                                        var salt='';
                                        contactId=currentAccountList[this.id].Contacts[0].Id;
                                        if(currentAccountList[this.id].Contacts[0].Salutation != undefined){
                                            salt=currentAccountList[this.id].Contacts[0].Salutation;}
                                        $j('#AccConName').html(salt+' '+currentAccountList[this.id].Contacts[0].Name);
                                        if(currentAccountList[this.id].Contacts[0].Name==""){
                                            $j('#addContact').show();
                                        }
                                        else
                                        {
                                            $j('#addContact').hide();
                                           
                                        }
                                        $j('#AccPhn').html(currentAccountList[this.id].Contacts[0].Phone);
                                        // alert(currentAccountList[this.id].Total_Order_Arrangements__c);
                                        $j('#LGA').html(currentAccountList[this.id].FloraMobileApp__LGA_Name__c);
                                        $j('#ST').html(currentAccountList[this.id].FloraMobileApp__Stage__c);
                                        $j('#TOA').html(currentAccountList[this.id].FloraMobileApp__Total_Order_Arrangements__c);
                                        $j('#TA').html(currentAccountList[this.id].FloraMobileApp__Trial_Arrangements__c);
                                        $j('#Industry').html(currentAccountList[this.id].Industry);
                                       
                                    }
                                   
                                    // $j('#accountName').val(currentAccountList[this.id].Name);
                                    $j.mobile.hidePageLoadingMsg();
                                    //alert('Testing')
                                    $j.mobile.changePage('#detailpage', {changeHash: true});
                                }).appendTo('#listMainList').show();
                            });
                           
                        }
                    }
                    },{escape: true,maxretries: 2 });
            }else{
                $j('#listMainList').html("");
            }
        }
        function hasSessionExpired(event) {
            return (event.type == "exception" && event.message.indexOf("Logged in?") != -1);
        }

Thanks & Regards
Siva.
Hi, I am not a developer and I need help. I have a client that is using GravityPlus Salesforce API and suddenly is getting an invalid session and expired access error. This form was previously functioning and still works when they do a test entry.

I have change the IP Relaxation to Relax IP restrictions and left Refresh Token Policy as Refresh token is valid until revoked. But the client is still getting an error.

Below the client has provided the error log:
2018-03-19 10:24:24.809132 - DEBUG --> GFP_Salesforce_OAuth2::request_access_token
2018-03-19 10:24:24.809220 - DEBUG --> Using refresh token
2018-03-19 10:24:24.809302 - DEBUG --> GFP_Salesforce_OAuth2::make_request
2018-03-19 10:24:24.809386 - DEBUG --> API URL: https://login.salesforce.com/services/oauth2/token
2018-03-19 10:24:24.809468 - DEBUG --> Parameters:Array
(
[client_id] => 3MVG9g9rbsTkKnAVKlnBCMYcCc9YsOGFcvaelLX4CS5oFYUicm0seZwlyXTdfy4gaKLSavUpUultcWNrf0VS5
[redirect_uri] => https://www.kendal.org/?callback=gravityformssalesforce
[client_secret] => 615469769594236820
[grant_type] => refresh_token
[refresh_token] => 5Aep861hJJeETRTRP.s1Gw5CwUMhk3sdiAeMgbGFqyK06wDF0EWmWBAmF4QK4iIXm59pU_fvc3lz4W46ChaC.Ts
)

2018-03-19 10:24:24.809542 - DEBUG --> Method: POST
2018-03-19 10:24:24.809632 - DEBUG --> Arguments: Array
(
[timeout] => 30
[sslverify] =>
[headers] => Array
(
)

[body] => Array
(
[client_id] => 3MVG9g9rbsTkKnAVKlnBCMYcCc9YsOGFcvaelLX4CS5oFYUicm0seZwlyXTdfy4gaKLSavUpUultcWNrf0VS5
[redirect_uri] => https://www.kendal.org/?callback=gravityformssalesforce
[client_secret] => 615469769594236820
[grant_type] => refresh_token
[refresh_token] => 5Aep861hJJeETRTRP.s1Gw5CwUMhk3sdiAeMgbGFqyK06wDF0EWmWBAmF4QK4iIXm59pU_fvc3lz4W46ChaC.Ts
)

)

2018-03-19 10:24:25.006310 - ERROR --> Error: Array
(
[error] => invalid_grant
[error_description] => expired access/refresh token
)

2018-03-19 10:24:25.006438 - DEBUG --> response did not have an access token
2018-03-19 10:24:29.812345 - DEBUG --> GFP_Salesforce_OAuth2::make_request
2018-03-19 10:24:29.812
 
Hi, I am using the rest api query and I need to get the label that appear on salesforce but I don't know how to do it.
For example if I want the value and de label it would be something like : query?q=select Custom__c, Custom__c.label from Account 
Thanks
Hi,
I would like to write a trigger  to create two tasks when ever lead is created....

Regards,
Sucharitha.
hey my triggerhandler is as follow 

public class WorkOrderTriggerHandler {    
    //Handles On Before UpDate event for this object.
    public static void onBeforeUpdate(List<Service_Order__c> orderList) {
        SubmitforApproval(orderList); 
    }
    
    // Checks if Submit for Approval is clicked then it change the Milestone of Project Phase
    public static void SubmitforApproval(List<Service_Order__c> orderList){
        list<Project_Phase__c> phaselist = new list<Project_Phase__c>();
        for(Service_Order__c workOrder : orderList){
            if(workOrder.IsSubmitforApproval__c){
                if(workOrder.Project_Phase__c != null){
                    Project_Phase__c phase = new Project_Phase__c( id = workOrder.Project_Phase__c);
                    phase.Milestone__c = 'Schedule Requested';
                    phaselist.add(phase);
                }
                workOrder.IsSubmitforApproval__c = false;
            }
        }
        
        update phaselist;
    }
}


Trigger :- 

trigger WorkOrder_Trigger on Service_Order__c (before update,after insert, after update) 
{
    // Handle Before Update event and calling the Handler method.
    if(trigger.isUpdate && trigger.isbefore) {
        WorkOrderTriggerHandler.onBeforeUpdate(Trigger.New);
    }
}

i need help with testclass for this can anyone please help 
I'm working on a trigger where i need to convert month name to integer value and i dont want to hard code like 'jan' = 1. Plz suggest.
Hi guys,

I have created Rest API to integrate Salesforce with banking system.
I am facing problem with HmacSha256 encryption. I am using as below:

Blob blobSign = Crypto.generateMac('Hmac-SHA256', Blob.valueOf(privKey + xmlOutput.length() + unixTime));
String HMACKey = EncodingUtil.base64Encode(blobSign);

I am getting error 403.

Any one know how to connect external system. 

Thanks in advance.

Need to make a decision on whether to use Person Account or Contact on my Org.

Essentially, I need to be able to link a contact to more than one Account - I was thinking of using Contact Roles for this, but it's been suggested i can use Person Account instead. What's the general opinion and main issues with both solutions?

Many thanks,
Nick

Hi , 
Currently we can see no of likes for chatter post.Like is it possible to count no of views for single chatter post?

Regards
Siva.
Hi , 

I have read salesforce documents for single sign on. SSO possible with two approaches

1. SAML 
2. Delegated Authentication.

is single sign on possible with oAuth authentication process? if yes, please help any doc link related to that?

Thanks in Advance.

Regards
Siva.
 
Hi,

We have created VF page and set us default landing page in place of chatter. Once user login , it is mandatory to read content in VF page and agree on that.

User able to click navigation bar and clicking another tab without accepting terms & conditions?

Thanks & Regards
Siva.
Hi , 

I have requirement to build custom reports for sales people performance for current financial years. We have going display data based user selection but each user's data crossing 60,000 + records. As per SOQL query limit for rows is 50000. 

Please help to handle this situation?

Thanks 
SIva.
Hi,  I receive the following error in a test class but have not been able to repeat them in non test running scenarios.

"System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. 
A flow trigger failed to execute the flow with version ID 301O00000008hM6. 
Contact your administrator for help.: []"

Does anyone know if there could be an issue running flows in test class contexts but not otherwise?

Thanks.
VF Page:

<apex:page sidebar="false" controller="asd">
<apex:form id="abc">
<apex:actionFunction name="a1" action="{!checkparam}" reRender="foo">
<apex:param id="aname" value="" name="param1" assignTo="{!g1}"/>
</apex:actionFunction>
{!g1}
</apex:form>
<button type="button" onclick="a1('page1')">Click Me </button>

</apex:page>

Controller:

public class asd {
    public string g1{
    get {
    g1='getter';
    return g1;
    }
    set{
    g1='setter';
    }
    }
public asd(){
g1='cons';
}
    public void checkparam() {
    system.debug('$$$'+g1);
    }

}

Above are the page and the controller,on clicking the button click me I am passing the parameter to a Apex method in the controller.
but evrytime I got "getter" value in the debug statement in the method checkparam (above class).
Is it like whatever is their in the getter method I will be getting that value only in the methods irrespective of any modification???
Now if I change my code to :

public class asd {
    public string g1{get ;set}
public asd(){
g1='cons';
}
    public void checkparam() {
    system.debug('$$$'+g1);
    }

}

I am able to get the page value in the controller method debug statement.

Can anyone have any idea on this behaviour???

 
How to build "Yes and No" Buttons in Email template?Here My requrement was iam sending email template through Url.It was working fine.But now i nedd to change in that one.That is i want to add "yes and  No " buttons in that email template.when the reciepient click on "yes" button then the Case should be automatically close & status feild should be updated? Can any one help me plz?
Hi, 

We have requirement to share one account with multiple users. Please suggest suitable approach to do ?

1. account teams - is account team works fine? is there any limiations use account teams?
2. custom object - admin will upload account code and owner code, write a trigger to share account record?

Thanks 
Hi,
First of all thanks for the time to see my question.
I have a encrypted data that comes from Java webservice(AES256-base64Encoded) :

C5j45mSEdqfz4f4GnrwR2T25tizY5gb3JoVNtWp8DiYOW5d+qvPx/ODmQIQqNXpZ1YkIjLwu5BAjDh3QmlrC4DKwTvbSrVqxh7OJdGDQy60ebp0o1cmLBCJuqzAOh2KAZC6L9v4wkwEb9dFOPesImY15DySPeyYiuLHL7n2dHmyVUMcDUrp9TAm85daCyG5mKhaAy2SP8iNBPoUBWSIDDEM7vG5Ganxu6JVzG4V6zGYQlLXAi33Ct9Fs99YE02KKR4kiw52eE1nS4hwReMZnP4vuU1FxM0BZfWAdUV8m9pQ=
Now I also have a 32 bit key to decode it (base64Encoded):

v3erqY/EGg1NI0yFHYLsMt7IuqJksxNjo1dlhsOo6Zs=

So after decryption, I should get the following data below:

http://b2bfsta.edc.cingular.net:8180/b2bservlets/TCMLoginDispatch.dyn?loginChannel=EBM&uid=B2c18e47fbc6e94ec7e5a92dece2c2684a4e3421a&sourceSystemId=iPhone6-NewOrder&profileType=PLATINUM&peDealId=o31634600562&enableDDR=true

I know if I encrypt in Apex then I can use decrypt(String, Blob, Blob, Blob) or decryptWithManagedIV(String, Blob, Blob).
But in this case, I don't why I am getting error, I tried all options available . PLease find sample code:

--------------------------------------------------------------------------------------------------------------------------------------------------------
Blob key = EncodingUtil.base64Decode('v3erqY/EGg1NI0yFHYLsMt7IuqJksxNjo1dlhsOo6Zs=');
String encodedData ='C5j45mSEdqfz4f4GnrwR2T25tizY5gb3JoVNtWp8DiYOW5d+qvPx/ODmQIQqNXpZ1YkIjLwu5BAjDh3QmlrC4DKwTvbSrVqxh7OJdGDQy60ebp0o1cmLBCJuqzAOh2KAZC6L9v4wkwEb9dFOPesImY15DySPeyYiuLHL7n2dHmyVUMcDUrp9TAm85daCyG5mKhaAy2SP8iNBPoUBWSIDDEM7vG5Ganxu6JVzG4V6zGYQlLXAi33Ct9Fs99YE02KKR4kiw52eE1nS4hwReMZnP4vuU1FxM0BZfWAdUV8m9pQ=';
Blob exampleIv = Blob.valueOf('Example of IV123');
Blob decryptedData = Crypto.decrypt('AES256', key ,exampleIv, EncodingUtil.base64Decode(encodedData));
//Blob decryptedData = Crypto.decryptWithManagedIV('AES256', key, EncodingUtil.base64Decode(encodedData));
 system.debug(decryptedData );  
--------------------------------------------------------------------------------------------------------------------------------------------------------
below is the java encrypted code, that can be refer:

public class EncryptionTest {

       public static final String CHAR_SET = "UTF8";
       
       public static void main(String[] args) {
              // TODO Auto-generated method stub
              //System.out.println("Hello World");
              String key = "v3erqY/EGg1NI0yFHYLsMt7IuqJksxNjo1dlhsOo6Zs=";
              
              // Try the below as well
              byte [] mKeyBytes = Base64.decodeBase64(key);
              //byte [] mKeyBytes = decodeToByteArray(key.getBytes());
              
              javax.crypto.Cipher mDecryptCipher = null;
              javax.crypto.Cipher mEncryptCipher = null;
              //byte[] mKeyBytes;
              
              try {
                     // Create the SecretKeySpec using the key in mKeyBytes
                     final SecretKeySpec skeySpec = new SecretKeySpec(mKeyBytes, getAlgorithmName());
                     // Create a new Cipher instance to do decryption using ALGORITHM
                     final javax.crypto.Cipher decryptCipher = javax.crypto.Cipher.getInstance(getAlgorithmName());
                     // Initialize this Cipher as a decryption cipher and pass in the key
                     // spec to use
                     decryptCipher.init(javax.crypto.Cipher.DECRYPT_MODE, skeySpec);
                     // If the previous two steps succeeded, set this new decryption
                     // Cipher to be this class's member decryption Cipher
                     mDecryptCipher = decryptCipher;
                     // Create a new Cipher instance to do encryption using ALGORITHM
                     final javax.crypto.Cipher encryptCipher = javax.crypto.Cipher.getInstance(getAlgorithmName());
                     // Initialize this Cipher as an encryption cipher and pass in the
                     // key spec to us
                     encryptCipher.init(javax.crypto.Cipher.ENCRYPT_MODE, skeySpec);
                     // If the previous two steps succeeded, set this new encryption
                     // Cipher to be this class's member encryption Cipher
                     mEncryptCipher = encryptCipher;
              } catch (InvalidKeyException e) {
                     System.out.println(e.getMessage());
                     e.printStackTrace();
              } catch (NoSuchAlgorithmException e) {
                     System.out.println(e.getMessage());
                     e.printStackTrace();
              } catch (NoSuchPaddingException e) {
                     System.out.println(e.getMessage());
                     e.printStackTrace();
              }
              
              String pStringToDecrypt = "C5j45mSEdqfz4f4GnrwR2T25tizY5gb3JoVNtWp8DiYOW5d+qvPx/ODmQIQqNXpZ1YkIjLwu5BAjDh3QmlrC4DKwTvbSrVqxh7OJdGDQy60ebp0o1cmLBCJuqzAOh2KAZC6L9v4wkwEb9dFOPesImY15DySPeyYiuLHL7n2dHmyVUMcDUrp9TAm85daCyG5mKhaAy2SP8iNBPoUBWSIDDEM7vG5Ganxu6JVzG4V6zGYQlLXAi33Ct9Fs99YE02KKR4kiw52eE1nS4hwReMZnP4vuU1FxM0BZfWAdUV8m9pQ=";
              
              //System.out.println("Hello");
              
              String decryptedString;
              final byte[] encryptedBytes;
              final byte[] decryptedBytes;
        try {
              encryptedBytes = Base64.decodeBase64(pStringToDecrypt.getBytes(CHAR_SET));
              decryptedBytes = decrypt(mDecryptCipher, encryptedBytes);
            decryptedString = new String(decryptedBytes, CHAR_SET);
            System.out.println(decryptedString);
        } catch (UnsupportedEncodingException e) {
              System.out.println(e.getMessage());
              e.printStackTrace();
        } catch (Exception e) {
              System.out.println(e.getMessage());
              e.printStackTrace();
        }
        
       }
       
       protected static final byte[] decrypt(javax.crypto.Cipher decryptCipher, byte[] pBytesToDecrypt) throws Exception {
              try {
                     return decryptCipher.doFinal(pBytesToDecrypt);
              } catch (IllegalBlockSizeException ibse) {
                     ibse.printStackTrace();
                     throw new Exception("Failed to decrypt: ", ibse);
              } catch (BadPaddingException bpe) {
                     bpe.printStackTrace();
                     throw new Exception("Failed to decrypt: ", bpe);
              }
       }

       public static String getAlgorithmName() {
              return "AES";
       }

}
--------------------------------------------------------------------------------------------------------------------------------------------------------

The problem is that the encrypted code is not getting decrypted in apex using standard way . Please help me out.
Hi All., 

I have created list view on account object. i have given permission to all users to see that list view. 

I have logged into salesforce1 with other user who have admin access but not able to see that list view.

if that user logged through browser, click on that list view , then that list view available in salesforce1

please help me how to get list view in salesforce1 without user clicking thorugh browser.

Thanks in advance



 
Hi, 

We have built salesforce hybrid mobile application to one of my customer. It is working both offline and online.  We have problem in syncing data once app closed. 
Currently we have setup "Manual" sync button to sync records between hybrid app and sf server but app should be open while syncing data.

We are plan to write native android background services to sync every 1 hours automatically withoout opening app. 

Can you please suggest process to call native android services using hybrid app (smart store)? 


Thanks in advance.



Hi.

In the VF I used the date format as YYYY-MM-dd in the 
<apex:outputText value="{0,date,YYYY/MM/dd}">
Before the last week of the year it was OK. When the new year falls in the  last week of Decemeber comes the issue.
For example
2014:
S   M  T  W Th F Sat
28 29 30 31 1   2 3

In the above calendar 1st Jan of 2015 falls in the Thurusday.So when I viewd the records of 28,29,30 of December 2014 It showed as
2015-12-28
2015-12-29
2015-12-30
2015-12-31

After that I came to know that
@"YYYY" is week-based calendar year.
@"yyyy" is ordinary calendar year.
http://realmacsoftware.com/blog/working-with-date-and-time

cheers
suresh