Skip to main content
added 61 characters in body
Source Link
Jayant Das
  • 30.7k
  • 3
  • 42
  • 68

But the problem is that for each field it is taking 4 to 5 seconds to update the FLS. Is there any way that we can have all the changes in the list and update the FLS in bulk.

Because you are adding the FLS within the iteration and that for every iteration, you are making an API call to update the FLS on the profile.

In order to what you are trying to do, I would try something as below.

  1. Declare an array of ProfileFieldLevelSecurity [] outside the loop
  2. Add the respective ProfileFieldLevelSecurity within the loop into that array
  3. Set the array on the profile outside the loop
  4. Invoke the API just once, outside the loop

int index = 0;

// declare an array of ProfileFieldLevelSecurity outside the loop
ProfileFieldLevelSecurity [] fieldArray = new ProfileFieldLevelSecurity [updateReadList.length]; // or size() depending if updateReadList is an array or list

for(String field:updateReadList) {      
    ProfileFieldLevelSecurity fieldSec = new ProfileFieldLevelSecurity();

    fieldSec.setField(field);
    fieldSec.setReadable(true);
    fieldSec.setEditable(false);
    
    fieldArray[index++] = fieldSec; // add all the FLS attributes to an array
}

admin.setFieldPermissions(fieldArray); // set all field permissions added in the array out of the loop
api.updateMetadata(new Metadata[] {admin}); // call the update in bulk - just one single call

But the problem is that for each field it is taking 4 to 5 seconds to update the FLS. Is there any way that we can have all the changes in the list and update the FLS in bulk.

Because you are adding the FLS within the iteration and that for every iteration, you are making an API call to update the FLS on the profile.

In order to what you are trying to do, I would try something as below.

  1. Declare an array of ProfileFieldLevelSecurity [] outside the loop
  2. Add the respective ProfileFieldLevelSecurity within the loop into that array
  3. Set the array on the profile outside the loop
  4. Invoke the API just once, outside the loop

int index = 0;

// declare an array of ProfileFieldLevelSecurity outside the loop
ProfileFieldLevelSecurity [] fieldArray = new ProfileFieldLevelSecurity [updateReadList.length];

for(String field:updateReadList) {      
    ProfileFieldLevelSecurity fieldSec = new ProfileFieldLevelSecurity();

    fieldSec.setField(field);
    fieldSec.setReadable(true);
    fieldSec.setEditable(false);
    
    fieldArray[index++] = fieldSec; // add all the FLS attributes to an array
}

admin.setFieldPermissions(fieldArray); // set all field permissions added in the array out of the loop
api.updateMetadata(new Metadata[] {admin}); // call the update in bulk - just one single call

But the problem is that for each field it is taking 4 to 5 seconds to update the FLS. Is there any way that we can have all the changes in the list and update the FLS in bulk.

Because you are adding the FLS within the iteration and that for every iteration, you are making an API call to update the FLS on the profile.

In order to what you are trying to do, I would try something as below.

  1. Declare an array of ProfileFieldLevelSecurity [] outside the loop
  2. Add the respective ProfileFieldLevelSecurity within the loop into that array
  3. Set the array on the profile outside the loop
  4. Invoke the API just once, outside the loop

int index = 0;

// declare an array of ProfileFieldLevelSecurity outside the loop
ProfileFieldLevelSecurity [] fieldArray = new ProfileFieldLevelSecurity [updateReadList.length]; // or size() depending if updateReadList is an array or list

for(String field:updateReadList) {      
    ProfileFieldLevelSecurity fieldSec = new ProfileFieldLevelSecurity();

    fieldSec.setField(field);
    fieldSec.setReadable(true);
    fieldSec.setEditable(false);
    
    fieldArray[index++] = fieldSec; // add all the FLS attributes to an array
}

admin.setFieldPermissions(fieldArray); // set all field permissions added in the array out of the loop
api.updateMetadata(new Metadata[] {admin}); // call the update in bulk - just one single call
added 272 characters in body
Source Link
Jayant Das
  • 30.7k
  • 3
  • 42
  • 68

But the problem is that for each field it is taking 4 to 5 seconds to update the FLS. Is there any way that we can have all the changes in the list and update the FLS in bulk.

Because you are adding the FLS within the iteration and that for every iteration, you are making an API call to update the FLS on the profile.

In order to what you are trying to do, I would try something as below:.

  1. Declare an array of ProfileFieldLevelSecurity [] outside the loop
  2. Add the respective ProfileFieldLevelSecurity within the loop into that array
  3. Set the array on the profile outside the loop
  4. Invoke the API just once, outside the loop

int index = 0;

// declare an array of ProfileFieldLevelSecurity outside the loop
ProfileFieldLevelSecurity [] fieldArray = new ProfileFieldLevelSecurity [updateReadList.length];

for(String field:updateReadList) {      
    ProfileFieldLevelSecurity fieldSec = new ProfileFieldLevelSecurity();

    fieldSec.setField(field);
    fieldSec.setReadable(true);
    fieldSec.setEditable(false);
    
    fieldArray[index++] = fieldSec; // add all the FLS attributes to an array
}

admin.setFieldPermissions(fieldArray); // set all field permissions added in the array out of the loop
api.updateMetadata(new Metadata[] {admin}); // call the update in bulk - just one single call

But the problem is that for each field it is taking 4 to 5 seconds to update the FLS. Is there any way that we can have all the changes in the list and update the FLS in bulk.

Because you are adding the FLS within the iteration and that for every iteration, you are making an API call to update the FLS on the profile.

In order to what you are trying to do, I would try something as below:

int index = 0;

// declare an array of ProfileFieldLevelSecurity outside the loop
ProfileFieldLevelSecurity [] fieldArray = new ProfileFieldLevelSecurity [updateReadList.length];

for(String field:updateReadList) {      
    ProfileFieldLevelSecurity fieldSec = new ProfileFieldLevelSecurity();

    fieldSec.setField(field);
    fieldSec.setReadable(true);
    fieldSec.setEditable(false);
    
    fieldArray[index++] = fieldSec; // add all the FLS attributes to an array
}

admin.setFieldPermissions(fieldArray); // set all field permissions added in the array out of the loop
api.updateMetadata(new Metadata[] {admin}); // call the update in bulk - just one single call

But the problem is that for each field it is taking 4 to 5 seconds to update the FLS. Is there any way that we can have all the changes in the list and update the FLS in bulk.

Because you are adding the FLS within the iteration and that for every iteration, you are making an API call to update the FLS on the profile.

In order to what you are trying to do, I would try something as below.

  1. Declare an array of ProfileFieldLevelSecurity [] outside the loop
  2. Add the respective ProfileFieldLevelSecurity within the loop into that array
  3. Set the array on the profile outside the loop
  4. Invoke the API just once, outside the loop

int index = 0;

// declare an array of ProfileFieldLevelSecurity outside the loop
ProfileFieldLevelSecurity [] fieldArray = new ProfileFieldLevelSecurity [updateReadList.length];

for(String field:updateReadList) {      
    ProfileFieldLevelSecurity fieldSec = new ProfileFieldLevelSecurity();

    fieldSec.setField(field);
    fieldSec.setReadable(true);
    fieldSec.setEditable(false);
    
    fieldArray[index++] = fieldSec; // add all the FLS attributes to an array
}

admin.setFieldPermissions(fieldArray); // set all field permissions added in the array out of the loop
api.updateMetadata(new Metadata[] {admin}); // call the update in bulk - just one single call
added 123 characters in body; added 373 characters in body
Source Link
Jayant Das
  • 30.7k
  • 3
  • 42
  • 68

But the problem is that for each field it is taking 4 to 5 seconds to update the FLS. Is there any way that we can have all the changes in the list and update the FLS in bulk.

Because you are adding the FLS within the iteration and that for every iteration, you are making an API call to update the FLS on the profile.

In order to what you are trying to do, I would try something as below:

int index = 0;

// declare an array of ProfileFieldLevelSecurity outside the loop
ProfileFieldLevelSecurity [] fieldArray = new ProfileFieldLevelSecurity [updateReadList.length];

for(String field:updateReadList) {      
    ProfileFieldLevelSecurity fieldSec = new ProfileFieldLevelSecurity();

    fieldSec.setField(field);
    fieldSec.setReadable(true);
    fieldSec.setEditable(false);
    
    fieldArray[index++] = fieldSec; // add all the FLS attributes to an array
}

admin.setFieldPermissions(fieldArray); // set all field permissions added in the array out of the loop
api.updateMetadata(new Metadata[] {admin}); // call the udpateupdate in bulk - just one single call

I would try something as:

int index = 0;
ProfileFieldLevelSecurity [] fieldArray = new ProfileFieldLevelSecurity [updateReadList.length];

for(String field:updateReadList) {      
    ProfileFieldLevelSecurity fieldSec = new ProfileFieldLevelSecurity();

    fieldSec.setField(field);
    fieldSec.setReadable(true);
    fieldSec.setEditable(false);
    
    fieldArray[index++] = fieldSec; // add all the FLS attributes to an array
}

admin.setFieldPermissions(fieldArray); // set field permissions out of the loop
api.updateMetadata(new Metadata[] {admin}); // call the udpate in bulk

But the problem is that for each field it is taking 4 to 5 seconds to update the FLS. Is there any way that we can have all the changes in the list and update the FLS in bulk.

Because you are adding the FLS within the iteration and that for every iteration, you are making an API call to update the FLS on the profile.

In order to what you are trying to do, I would try something as below:

int index = 0;

// declare an array of ProfileFieldLevelSecurity outside the loop
ProfileFieldLevelSecurity [] fieldArray = new ProfileFieldLevelSecurity [updateReadList.length];

for(String field:updateReadList) {      
    ProfileFieldLevelSecurity fieldSec = new ProfileFieldLevelSecurity();

    fieldSec.setField(field);
    fieldSec.setReadable(true);
    fieldSec.setEditable(false);
    
    fieldArray[index++] = fieldSec; // add all the FLS attributes to an array
}

admin.setFieldPermissions(fieldArray); // set all field permissions added in the array out of the loop
api.updateMetadata(new Metadata[] {admin}); // call the update in bulk - just one single call
Source Link
Jayant Das
  • 30.7k
  • 3
  • 42
  • 68
Loading