how to hide approve/Reject links in the home page?

how to hide approve/Reject links in the home page?

We can hide the approve/Reject links, If we want to restrict the user to approve the record from home page.

If we have implemented logic for the approval process (customized approval process) for that we have to override the all the links (Approve links) and buttons in the details page.

How we can restrict the user to approve from home page.

Steps:

  • Create a StaticResouce “StaticResourceName” upload a JS file. (File extension should be .JS)

var j$ = jQuery.noConflict();

j$(document).ready(function(){

j$(“table.list td.actionColumn”).html(”);

});

  • go to Setup > Home > Custom Links
  • create a new link call it “HideApproveLink”
  • Behaviour = “Execute JavaScript”
  • Content Source = “Onclick JavaScript”
  • at the body enter {!REQUIRESCRIPT(“/resource/StaticResourceName”)}
  • go to Setup > Home > Home Page Components à New
  • call it “HideApproveLink-Box”
  • pick type “Links”
  • click next
  • pick “HideApprovalLink” we created above à save
  • got to Setup > Home > Home Page Layouts
  • add “HideApprovalLink-box” to your layout
  • Click on home Tab you can see the Approva/Reject links are hidden in the page.

We can create a home page component and written script to hide the links. But from summer ‘15 we don’t have the capability to write the script in home page component.

Disabling the command buttons and Grey out the total vf page on any action

How to disable the command buttons and Grey out the total vf page on any action?

Usually we multiple records creates whenever multiple click on save button on custom save button on VF page. So to overcome this issue we can hide the all buttons once user click on buttons.

VF Page:

<apex:commandButton action=”{!doSave}” id=”saveButton ” value=”save” onclick=”disableAllButtons()”/>

<apex:commandButton action=”{!doCancel}” id=”cancelButton” value=”cancel” onclick=” disableAllButtons()”/>

<Script>

var j$ = jQuery.noConflict();

function disableAllButtons(){

j$(“[id$= saveButton],[id$= cancelButton]”).hide();

}

function showButtons(){

j$(“[id$= cancelButton],[id$= saveButton]”).show();

}

</Script>

  • showButtons function is to show the button once the action.
  • If we can use the same code for the input fields as well which have the action function. So that we can restrict the user to change the field and click the buttons immediately.
  • Some times we have to restrict the user to modify the fields on that page after click on button or change on any fields of having action function.

So, here we have to grey out the total VF page to restrict the user to change the fields if any action is In-progress.

The below code is to grey out the page. Gering out the backgrouond,status box and all tex boxes in the page.

<apex:commandButton action=”{!doSave}” id=”saveButton ” value=”save” onclick=”disableAllButtons()”/>

<apex:commandButton action=”{!doCancel}” id=”cancelButton” value=”cancel” onclick=” disableAllButtons()”/>

<div id=”processingSimbol” style=”display:none;”>

“Processing…….”     </div>

<Script>

var j$ = jQuery.noConflict();

function disableAllButtons(){

j$(“[id$= saveButton],[id$= cancelButton]”).hide();

j$(“# processingSimbol “).show();

j$(“[id$=formId]”).append(j$(“<div>”,{“id”:”blurybackground”})

,j$(“<div>”,{“id”:”statusBox”})

.append(

j$(“<img>”,{“src”:”/img/loading32.gif”}),

j$(“<div>”,{“id”:”textBox”}).text(“{!$Label.MDF_Status_Processing}”)));

}

function showButtons(){

j$(“[id$= cancelButton],[id$= saveButton]”).show();

j$(“#blurybackground, #statusBox”).remove();

if(globalFocus != null){

globalFocus.focus();

if(globalFocus.attr(‘class’).indexOf(‘amountInput’)!=-1){

var focusId = globalFocus.attr(‘id’).split(‘:’).join(‘\\\\:’);

setTimeout(function(){

j$(“#”+focusId).focus();

},300);

}

}

}

</Script>

<style>

#blurybackground {

z-index:1000;

//bottom:0;

position:absolute;

left:0px;

top:0px;

width:100%;

height:100%;

text-align:center;

vertical-align: middle;

background-color: #222;

opacity:0.6;

filter:alpha(opacity=60);

}

#statusBox {

// for Modzilla

-moz-background-clip:border;

-moz-background-inline-policy:continuous;

-moz-background-origin:padding;

-moz-border-radius-bottomleft:5px;

-moz-border-radius-bottomright:5px;

-moz-border-radius-topleft:5px;

-moz-border-radius-topright:5px;

-moz-box-shadow:1px 6px 5px #888888;

-webkit-border-bottom-left-radius:5px;

-webkit-border-bottom-right-radius:5px;

-webkit-border-top-left-radius:5px;

-webkit-border-top-right-radius:5px;

-webkit-box-shadow:1px 6px 5px #888888;

box-shadow: 1px 6px 5px #888888;

z-index:1000;

background:#FFFFFF none repeat scroll 0 0;

height:42px;

width:150px;

left:45%;

top:35%;

padding-left:15px;

padding-top:11px;

position:absolute;

vertical-align:middle;

}

#textBox {

margin-left:40px;

margin-top:-20px;

font-weight:bold;

font-size:14px;

}

</style>

Interview questions on visualforce pages – 2

Interview questions on visualforce pages – 2

11. What is <apex:form> tag?

<Apex:form> tag allow a section of a visualforce page to enter input values & Buttons to submit it. The body of the form tag contains, how data is placed & how it is process. The best practice is to use only one form tag in page.

12. What is <apex:pageBlock> tag?

<Apex:pageBlock> helps you to provide standard salesforce detail page look and feel in your visual force pages without any default content.

13.What is <apex:pageBlockSection> tag?

<apex:pageBlockSection> tag represents a section of data with in an <apex:pageBlock> component, which is similar to a section in a standard salesforce page layout. In page block section we can define number of columns required to display in a single page. This component must be a child <apex:pageBlock>

14. What is <apex:pageBlockButtons>?

<apex:pageBlockButtons> tag is used to display buttons & links in salesforce standard format. This tag must be a child of <apex:pageBlock>

15. Can we define <apex:pageBlockButtons> under <apex:pageBlockSection> tag?

No, <apex:pageBlockButtons> must be direct child of <apex:pageBlock> tag.

Visualforce page to explain about tags mentioned in above questions.

<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Content Section" columns="2">           
                <apex:inputField value="{!account.name}"/>                
                <apex:inputField value="{!account.type}"/>                
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 This code displays a small form to enter account name & type. See the below screen to see the output of above code.

Interview questions on visualforce pages - 2

Fieldset in salesforce

What is a fieldset?

In this section i will explain about what is a fieldset? How can we create that? and how can we use that in a visualforce page?

Fieldset is a grouping of fields, you can use this fieldset in visualforce page to display that group of fields in that page. If you are using field set in visualforce to display fields, then you can add, remove & reorder fields very easily. No need to do code modifications to the page, In fieldset only you can add, remove & reorder fields. Generally these field sets are useful in managed packages. In manged packages , If you used field set in visualforce pages, administrators can easily add, remove and reorder fields in page. As an administrator, you can create or edit field sets and also you can edit installed fieldsets.

How to create a fieldset?

To create a fieldset, go to object, you want create fieldset by clicking on new button. Enter required fields and save. We will get below screen to add fields to field set.

Fieldset In Salesforce

Using fieldsets is very easy & you can drag and drop to arrange fields in fieldsets.

How to use field set in a visualforce page?

Below code is simple visualforce, it explains about how to use fieldset in a visualforce page.

<apex:page id=”pageId” standardcontroller=”Registration__c”>
<apex:form id=”formId”>
<apex:pageblock id=”pb”>
<apex:pageBlockSection >
<apex:repeat value=”{!$ObjectType.Registration__c.FieldSets.Registration_req_fields}” var=”fs”>
<apex:inputfield value=”{!Registration__c[fs]}”>
</apex:inputfield></apex:repeat>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value=”Submit Details” action=”{!Save}”/>
</apex:pageBlockButtons>
</apex:pageblock>
</apex:form>
</apex:page>

The above code displays all fields in the field set. See the below screen to see the output of above code.

Fieldset

No need to change the code to re arrange fields in this page. What ever the order you created/edited in field set, the same order will display on this page.

We can easily make fields required. It is drag drop tool like page layout. To make required, double click on the field and check the required check box.

Important point about field sets:

– In the field set, you can span to fields that reference multiple objects. When you span a field into a field set that references multiple objects, the only field you can span to is the Name object.

– The total number of cross object spans within the In the Field Set container can’t exceed 25.

Password polices at profile level

Now you can manage password policies at profile level in salesforce

In winter’15 release salesforce has provided this feature to mange password policies like password expire in, history, length, complexity requirement, maximum invalid login attempts and lockout effective period at profile level. Earlier this option is available at organization level. Now with this winter’15 release this option is available at profile level also.

Until you set the password policies on profile, the organization policies will apply to users. Once you set the password policies at profile level, it will override organization changes. After setting password policies at profile level, if you change these settings at org – level, it won’t impact. profile settings will only apply when set these settings at profile level.

How we can set this at organization level

To find these settings at organization level, go to Settings -> Administer -> Under security controls you will find this option. see the below screen to understand.

password policies How can set this at profile level:

To find these settings at profile level, go to settings -> Administer -> Manage users -> profiles -> Select the profile you want to change and edit the profile to change these settings. see the below screen for reference.

password policies

 This option is available in Enterprise, performance, Unlimited and Developer editions. Need below User permissions required to edit session & password settings in profiles.

Manage permission sets & PROFILES and manage password policies.