function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anil MalneniAnil Malneni 

How to set default values for close date and opportunity name on opportunity create in SF1

I would like to pre-populate the opportunity name and close date values on opportunity record creation. because these 2 fields are standard and required fields, which we can't remove from page layout.

My user's dont want to enter these fields on record creation...

Thanks in Advance....
Sandeep WaliaSandeep Walia
Hi Anil,
I would suggest youto read this answer (Specifically the best answer and @NIckPanter's answer)
https://success.salesforce.com/answers?id=90630000000grJWAAY
Hope this helps....
Anil MalneniAnil Malneni
Thank you for your reply sandeep...

All workflow rules will work only after system validation rules (i.e required fields on page layout)..
Here I would like to pre-populate the opportunity name and close date values after clicking on the New button on Opportunity TAB.

Thanks....
Mahesh DMahesh D
Hi Anil,

Try Publisher Actions for SF1.

https://developer.salesforce.com/docs/atlas.en-us.salesforce1.meta/salesforce1/actions_intro.htm

If the above solution doesn't work then we may need to override the new button and make sure that the values are pre-populating as part of the Opportunity creation.

Regards,
Mahesh
Sandeep WaliaSandeep Walia

You can use a custom button to prepoulate the field then...

Try this solution

https://success.salesforce.com/answers?id=90630000000gwOIAAY

Anil MalneniAnil Malneni
Thank you Mahesh and Sandeep....

 I have override the New button on Opportunity object with below line.

/006/e?&opp3={!Account.Name}&opp9='02/02/2050'

Its working as expected in desktop, but Not working on SF1 (IPad).

Note: Pagereference and url hacking is not working on SF1, workaround is we have to use sforce.one.NavigateToURL method..
I would like to know the syntax ( sforce.one.NavigateToURL) to populate this field values on SF1..


Thank you..
Anil MalneniAnil Malneni
--No luck Sandeep...

Here is the syntax look like...
  • sforce.one.navigateToURL("/006/e?opp3={!Account.Name}&opp9='02/02/2050'​ "); 

​But its not working in SF1 (Ipad)...Please correct the above syntax..if you have any idea...

Appreciate your help.....

Thanks,
Sandeep WaliaSandeep Walia

Hi Anil,

Was just going through a trailhead excersice and found this .....

Add Navigation Controls Using sforce.one
Connect your page to the Salesforce1 navigation system by using sforce.one navigation functions.
Visualforce pages running in Salesforce1 often have to interact with or link to other pages in the application. Common navigation functions are available through the sforce.one object, a JavaScript utility library automatically made available when running in Salesforce1.
Open the Developer Console and click File | Open, then open your page.
At the bottom of the script block, before the closing </script> tag, add the following code to your page.

ul.addEventListener("click", function(e) {
   sforce.one.navigateToSObject(e.target.getAttribute("data-id"));
});
 



Reload the app and view your changes.
Your mini app doesn’t look different at first. But try tapping an account. You’ll navigate to the account’s detail page, where you can view the account, the account feed, and so on. What’s more, by using sforce.one to navigate forward, you can also use the Salesforce1 back arrow to navigate back to where you started—your Latest Accounts page. Cool!
The navigation functions provided by sforce.one let you tie your custom app functionality into the overall Salesforce1 navigation system. This lets your pages behave just like built-in functionality when it comes to navigation. You can use different sforce.one functions to navigate to individual records, to specific feeds or feed items, to lists and related lists, and even to general URLs. See this unit’s resources for more details on this useful library.
Sources:
https://developer.salesforce.com/trailhead/visualforce_mobile_salesforce1/visualforce_mobile_salesforce1_nav_menu

https://developer.salesforce.com/docs/atlas.en-us.salesforce1.meta/salesforce1/salesforce1_dev_jsapi_sforce_one.htm

Maybe this could sove your problem.

Pramada Emmadi 2Pramada Emmadi 2
Anil, I have the same requirement. Could you please post the code here
Rajesh..Rajesh..
Pre populate close date field with default future date.

VF Page :


<apex:page StandardController="Opportunity" extensions="ClosedateOppyController" action="{!NavigateToURL}" >
</apex:page>

Apex Class :

public class ClosedateOppyController {     
public ClosedateOppyController(ApexPages.StandardController controller) {
    }
         public pagereference navigateToURL(){
        return new pageReference('/006/e?opp9=02/02/2050 &nooverride=1&isdtp=mn&retURL=/006/o');     
}
}

Open  buttons and links, select button and check  Visual Force page controller.