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
subhash-cogsubhash-cog 

Custom Mass edit (Not app exchange) doesnot work unless object level 'create' permission

Hi,

 

We are facing weird issue in custom mass edit functionality which we have developed by using standard list controller

 

VF page:-----

<apex:page standardController="Opportunity" recordSetVar="opportunities" extensions="selectedSizeWorkaround" tabStyle="Opportunity" sidebar="true" id="muopp">

    <apex:form id="muform">
   
        <apex:pageBlock title="Opportunity Mass-edit" mode="edit" id="mub1">
            <apex:pageMessages />
            <apex:pageBlockButtons >
               <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!Cancel}"/>
            </apex:pageBlockButtons>
            
            <apex:pageBlockTable value="{!selected}" var="opp" id="muform">
                <apex:column value="{!opp.Id}"/>
                <apex:column value="{!opp.name}"/>
                <apex:column value="{!opp.AccountId}"/>
                <apex:column value="{!opp.Application_Number__c}"/>
                <apex:column value="{!opp.Application_Date__c}"/>
                <apex:column value="{!opp.Amount}"/>
                <apex:column value="{!opp.StageName}"/>                              
                <apex:column headerValue="Probability">
                     <apex:inputField value="{!opp.Probability}" id="stagename">
                    <apex:actionSupport event="onchange" rerender="muselectedlist"/>
                </apex:inputField>
                </apex:column>               
             </apex:pageBlockTable>      
        </apex:pageBlock>
    </apex:form>
</apex:page>


Controller extension:----------------------------------

public class selectedSizeWorkaround {

    ApexPages.StandardSetController setCon;

    public selectedSizeWorkaround(ApexPages.StandardSetController controller) {
        setCon = controller;
    }

    public integer getMySelectedSize() {
        return setCon.getSelected().size();
    }
    public integer getMyRecordsSize() {
        return setCon.getRecords().size();
    }
}

Eventhough this code works and successfully edit the probability value of selected records provided the create permission on Opportunity object to the user (i.e. user's profile).
If the user doesnot have create permission on Opportunity and only have read and create permission on Opportunity,then he can not edit that.
As per our setup we can't give the create permision on opportunity (though those users have edit and read permission on Opportunity)to the users who wants to use mass edit custom functionlity


This is something wierd issue i am facing,if somebody faced this issue please let me know and if any workaround.
we can not use mass edit app exchange as well as we want to show only probability for edit to the users and not all fields.

 

Thanks,

subhash-cogsubhash-cog

One correction in Above..

 

Eventhough this code works and successfully edit the probability value of selected records provided the create permission on Opportunity object to the user (i.e. user's profile).
If the user doesnot have create permission on Opportunity and only have read and edit permission on Opportunity,then he can not successfully edit that.
As per our setup we can't give the create permision on opportunity (though those users have edit and read permission on Opportunity)to the users who wants to use mass edit custom functionlity


This is something wierd issue i am facing,if somebody faced this issue please let me know and if any workaround.
we can not use mass edit app exchange as well as we want to show only probability for edit to the users and not all fields.

 

atormanatorman

Hi Subhash-cog,

 

I was able to recreate your page and class successfully - thank you for the detailed steps. However, I had no problem using it with a user who only had Read and Edit permissions on Opportunities. 

 

The only thing I added to the scenario to make sure it worked was a permission set with access to both the apex page and class. 

 

Can you provide additional information on what happens when a user with only Read and Edit permissions clicks on the Mass Edit button from a list view after selecting several records? Do they see the page and get an error on save or do they not even get to the visualforce page? Thanks!

 

Adam

subhash-cogsubhash-cog

Hey Adam,

 

Issue is,when user whose profile has only read and edit permission on Opportunity tries to edit the Opportunites i.e.

 

user selects no of opportunity in the list view ,then hits the custom mass edit button(custom button points to VF page for mass edit),then with the VF page opens,When user changes the current probability value with new value and hits save then the selected opportunity records doesn't save with new probability value and shows only old probability value.

 

Please let me know if you are doing excatly the same and have read and edit permission on test user's profile..please don't use sys admin profile and try with custom profile for the test user..It will not work..Please let me know otherwise.

 

Thanks,

Subhash

 

LVSLVS

@Subash


Are you sure that's the problem? If the user didn't have permissions I would expect some kind of exception to be thrown - maybe there's some page logic missing that brings forth the old value or something?

 

Please give more details as to if you're getting any errors etc

 

~LVS

 

atormanatorman

Hi Subhash,

 

I've been digging into this and it may be that there is a bug here; however, there is an opportunity to work around this issue.

 

If you change your recordSetVar to be the same value ('selected') as your pageBlockTable's value, you'll notice that while we don't load a subset of items into the list, users without Create permission on Opportunities can make a change and it will store properly. There is an issue here where you are loading a set of items into the list but saving the probability changes from that list to a different variable.

 

I believe with some more logic on the controller, you could properly restrict the list to only the items selected. Unfortunately, I haven't had the time yet to create some options for you.

 

In the meantime, I'm continuing to investigate whether this is indeed a bug or not.

 

Thanks!

 

Adam