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
NM AdminNM Admin 

Display custom button based on the record availability

Hello,
I have a custom object Journey and I have a requirement that if the journey is not exist(Journey record is not created for the day) for the day then dispaly the 'Start' button on the vf page.
Once I click on the button it'll be hidden from the page and 'Stop' button will be display on the page.


Welcome to your suggestions!

Thanks,
Nilesh
Ashish DevAshish Dev
You can override a record detail/edit page with vf page. Conditionally show/hide buttons, what is the issue? Could you tell us what you have tried till now?
NagendraNagendra (Salesforce Developers) 
Hi,

May I suggest you please check with below idea from the success community with a similar discussion which might help you further. I would suggest you upvote for the idea so that this feature can be available in the mere future.

As a workaround, you can override detail page with the visual force page to show or hide the buttons.

Thanks,
Nagendra
NM AdminNM Admin
Hi Ashish,

Here is detailed requirement.
I'm fetching lat long and address from javascript and storing them into the custom object at the backend(from controller).
<apex:form id="frm">
        <apex:actionFunction name="iFoundYou" action="{!iFoundYou}" rerender="frm">     
            <apex:param id="lat" name="latitude" value="" assignTo="{!valueLat}"/>
            <apex:param id="long" name="longitude" value="" assignTo="{!valueLong}"/>
        </apex:actionFunction>
         <!--Learn about this code on MDN: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation -->
        <p><button type="Hidden" style="display:none" onclick="geoFindMe()" >Show my location</button></p>
        <div id="out"></div>
    </apex:form>
above is my current code at back end of this page making callout and storing record in the custom objects.
Now I want two buttons on the visualforce page which will be dispalyed based on the conditions:

START button: Please check there is record for the current date in journey object. If not, then START button should be visible. If yes, then STOP button should be visible
STOP button: the latitude ad longitide fetching mechanism should get stopped. This means as user will clicked on the stop button then there should no any record in the location object after that time for the respective journey.

I don't want to override the detail page.
Please take a look and suggest something.

Thanks,
Nilesh
Ashish DevAshish Dev
Is start and stop button on same page of which you have given the snippet above. 
NM AdminNM Admin
yes