• Urich NOUPIK
  • NEWBIE
  • 15 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 6
    Replies
Hi,
Please i need to have Profile Name with Object Access Permission by using Apex or SOQL. I use this query but the Profile name not appears corretly as you can see in the attached picture. Please someone can help me? I need it to extract metadate for a project.

SELECT Id, Parent.Name, Parent.Profile.Name, SobjectType, PermissionsCreate, PermissionsRead, PermissionsEdit, PermissionsDelete, PermissionsModifyAllRecords, PermissionsViewAllRecords FROM ObjectPermissions ORDER BY Parent.Name, SObjectType

User-added image
 
Hi, i want to export my record data in multi columns csv file (each columns per fields).
Now, i just export it in single column (field separated by comma) after clic on lightning button.
Someone can help me please. 
Below are the codes.

Application
<aura:application extends="force:slds">
    <c:project1Home/>
</aura:application>

project1Home.cmp
<aura:component controller="GenerateCSV" implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
    <aura:attribute name="ObPerLst" type="ObjectPermissions[]"></aura:attribute>
    <!--aura init handler , call js "loadAcctRcrds" function that use  "GenerateCSV" controller and load "ObPerLst" object-->   
    <aura:handler name="init" value="{!this}" action="{!c.loadAcctRcrds}"/>
    <!-- NEW FORM -->
    <lightning:layout>
        <lightning:layoutItem padding="around-small" size="6">
            <!-- Header -->
            <c:project1Header/>
            <!-- / Header -->
            <div aria-labelledby="ClicDiv">
                <!-- BOXED AREA -->
                <fieldset class="slds-box slds-theme--default slds-container--small">
                    <legend id="newMetadata" class="slds-text-heading--small 
                                                       slds-p-vertical--medium">
                        Generate profile's metadata
                    </legend>
                    
                    <!-- CREATE FORM -->
                    <form class="slds-form--stacked">
                        <!--<ui:inputText aura:id="n1" maxlength="5" size="5" label="Number1" required="true"/>
                        <ui:inputText aura:id="n2" maxlength="5" size="5" label="Number2" required="true"/>-->
                        <lightning:button label="Generate" 
                                          class="slds-m-top--medium"
                                          variant="brand"
                                          onclick="{!c.ClickExport }"  />
                    </form>
                    <!-- / CREATE FORM -->
                    {!v.body}
                </fieldset>
                <!-- / BOXED AREA -->
            </div>
        </lightning:layoutItem>
    </lightning:layout>
    <!-- / NEW FORM -->
</aura:component>

project1HomeController.js
({
    loadAcctRcrds:function(component,event,helper){
       var action = component.get("c.getObjectPermissions");
        action.setCallback(this,function(response){
        var state = response.getState();
            if(state == "SUCCESS"){
                component.set("v.ObPerLst",response.getReturnValue());
            }
            else{
                alert('failed');
            }
        });
        $A.enqueueAction(action);     
    },
    // ClickExport take component object "ObPerLst" load by init handler and convert it to csv file using helper method
    ClickExport : function(component, event, helper) {
         var stockData = component.get("v.ObPerLst") 
         var csv = helper.convertArrayOfObjectsToCSV(component,stockData);
          if (csv == null){return;} 

        // ####--code for create a temp. <a> html tag [link tag] for download the CSV file--####     
         var hiddenElement = document.createElement('a');
          hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
          hiddenElement.target = '_self'; // 
          hiddenElement.download = 'ExportData.csv';  // CSV file Name* [.csv extension is obligatory] 
          document.body.appendChild(hiddenElement); // Required for FireFox browser
          hiddenElement.click(); // using click() js function to download csv file
    }
   
})

project1HomeHelper.jsp
({
    convertArrayOfObjectsToCSV : function(component,objectRecords){
        // declare variables
        var csvStringResult, counter, keys, columnDivider, lineDivider,parentKey;
        // check if "objectRecords" parameter is null, then return from function
        if (objectRecords == null || !objectRecords.length) {
            return null;
         } 
        // store ,[comma] in columnDivider variable for sparate CSV values and 
        // for start next line use '\n' [new line] in lineDivider variable  
        columnDivider = ',';
        lineDivider =  '\n';

        // in the keys valirable store fields API Names as a key 
        // this labels use in CSV file header
        keys = ['Id','Parent','Parent','SobjectType','PermissionsCreate', 'PermissionsRead', 'PermissionsEdit', 'PermissionsDelete', 'PermissionsModifyAllRecords', 'PermissionsViewAllRecords' ];
        
        parentKey=['Id'];//parentKey=['AccountNumber'];

        csvStringResult = '';
        csvStringResult += keys.join(columnDivider);/* space header information here*/
        csvStringResult += lineDivider;

        for(var i=0; i < objectRecords.length; i++){   
            counter = 0;

             for(var sTempkey in keys) {
                 var skey = keys[sTempkey] ;
                 
                 // add , [comma] after every String value,. [except first]
                 if(counter > 0){
                     csvStringResult += columnDivider;
                 }
                 //csvStringResult += '"'+ objectRecords[i][skey]+'"';
                 if(typeof objectRecords[i][skey] === 'object'){
                     csvStringResult += '"'+ objectRecords[i][skey].Name+'"';
                 }else{
                     csvStringResult += '"'+ objectRecords[i][skey]+'"';
                 }
                
               counter++;

             } // inner for loop close     
             csvStringResult += lineDivider;
          }// outer main for loop close 

       // return the CSV formate String 
        return csvStringResult;        
    },
})

project1Header.cmp
<aura:component >
    <!-- PAGE HEADER -->
    <lightning:layout class="slds-page-header slds-page-header--object-home">
        <lightning:layoutItem>
            <lightning:icon iconName="action:goal" alternativeText="Generate metadata"/>
        </lightning:layoutItem>
        <lightning:layoutItem padding="horizontal-small">
            <div class="page-section page-header">
                <h1 class="slds-text-heading--label">Get out metadata</h1>
                <h2 class="slds-text-heading--medium">Get out my metadata</h2>
            </div>
        </lightning:layoutItem>
    </lightning:layout>
    <!-- / PAGE HEADER -->
</aura:component>

GenerateCSV.apxc
public Class GenerateCSV {
    @AuraEnabled
    public static List<ObjectPermissions> getObjectPermissions() {
        return [SELECT Id, Parent.Name, Parent.Profile.Name, SobjectType, PermissionsCreate, PermissionsRead, 
                PermissionsEdit, PermissionsDelete, PermissionsModifyAllRecords, PermissionsViewAllRecords 
                FROM ObjectPermissions
                ORDER BY Parent.Name, SObjectType];
                //ORDER BY Parent.Profile.Name, SObjectType];
    }
}
I can create a project on my Visual Studio Code editor due to my salesforce CLI installation. When i try verifying it version on the prompt i have this issue:
C:\Users\NOUPIK>sfdx plugins --core
 !    autoupdate:: C:\Users\NOUPIK\AppData\Local\sfdx\update.lock.readers.lock
 !    is locked
 !    C:\Users\NOUPIK\AppData\Local\sfdx\update.lock.readers.lock is locked

How can i solve it? 
Hi all,
I have this problem when creating a salesforce project on Visual Studio Code.
"Starting SFDX: Create Project
09:05:21.882 sfdx force:project:create --projectname HelloWorldLightningWebComponent --outputdir c:\Users\NOUPIK\Documents\Salesforce
! autoupdate:: C:\Users\NOUPIK\AppData\Local\sfdx\update.lock.readers.lock
! is locked
! C:\Users\NOUPIK\AppData\Local\sfdx\update.lock.readers.lock is locked
09:07:40.290 sfdx force:project:create --projectname HelloWorldLightningWebComponent --outputdir c:\Users\NOUPIK\Documents\Salesforce ended with exit code 1
"

Please i just follow the step on the Create a Hello World Lightning Web Component unit and select "SFDX: Create Project" command on VS Code after install salesforce extension pack corretly. But it look like the project  was not created. What is wrong?
Hi,
I am new in Salesforce and i want to create a development org in which you can create a simple app.
I have to use "Environnement hub" but i dont see it on my production org or in my Trailhead Playground. On the guide, we ask me to "Contact Salesforce to enable the Environment Hub in your org" and i dont know how to do it.
Someone can help me please.
here is my link guide : "https://developer.salesforce.com/docs/atlas.en-us.216.0.packagingGuide.meta/packagingGuide/environment_hub_get_started_configure_app.htm?search_text=environment%20hub"
Hi,
Please i need to have Profile Name with Object Access Permission by using Apex or SOQL. I use this query but the Profile name not appears corretly as you can see in the attached picture. Please someone can help me? I need it to extract metadate for a project.

SELECT Id, Parent.Name, Parent.Profile.Name, SobjectType, PermissionsCreate, PermissionsRead, PermissionsEdit, PermissionsDelete, PermissionsModifyAllRecords, PermissionsViewAllRecords FROM ObjectPermissions ORDER BY Parent.Name, SObjectType

User-added image
 
Hi, i want to export my record data in multi columns csv file (each columns per fields).
Now, i just export it in single column (field separated by comma) after clic on lightning button.
Someone can help me please. 
Below are the codes.

Application
<aura:application extends="force:slds">
    <c:project1Home/>
</aura:application>

project1Home.cmp
<aura:component controller="GenerateCSV" implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
    <aura:attribute name="ObPerLst" type="ObjectPermissions[]"></aura:attribute>
    <!--aura init handler , call js "loadAcctRcrds" function that use  "GenerateCSV" controller and load "ObPerLst" object-->   
    <aura:handler name="init" value="{!this}" action="{!c.loadAcctRcrds}"/>
    <!-- NEW FORM -->
    <lightning:layout>
        <lightning:layoutItem padding="around-small" size="6">
            <!-- Header -->
            <c:project1Header/>
            <!-- / Header -->
            <div aria-labelledby="ClicDiv">
                <!-- BOXED AREA -->
                <fieldset class="slds-box slds-theme--default slds-container--small">
                    <legend id="newMetadata" class="slds-text-heading--small 
                                                       slds-p-vertical--medium">
                        Generate profile's metadata
                    </legend>
                    
                    <!-- CREATE FORM -->
                    <form class="slds-form--stacked">
                        <!--<ui:inputText aura:id="n1" maxlength="5" size="5" label="Number1" required="true"/>
                        <ui:inputText aura:id="n2" maxlength="5" size="5" label="Number2" required="true"/>-->
                        <lightning:button label="Generate" 
                                          class="slds-m-top--medium"
                                          variant="brand"
                                          onclick="{!c.ClickExport }"  />
                    </form>
                    <!-- / CREATE FORM -->
                    {!v.body}
                </fieldset>
                <!-- / BOXED AREA -->
            </div>
        </lightning:layoutItem>
    </lightning:layout>
    <!-- / NEW FORM -->
</aura:component>

project1HomeController.js
({
    loadAcctRcrds:function(component,event,helper){
       var action = component.get("c.getObjectPermissions");
        action.setCallback(this,function(response){
        var state = response.getState();
            if(state == "SUCCESS"){
                component.set("v.ObPerLst",response.getReturnValue());
            }
            else{
                alert('failed');
            }
        });
        $A.enqueueAction(action);     
    },
    // ClickExport take component object "ObPerLst" load by init handler and convert it to csv file using helper method
    ClickExport : function(component, event, helper) {
         var stockData = component.get("v.ObPerLst") 
         var csv = helper.convertArrayOfObjectsToCSV(component,stockData);
          if (csv == null){return;} 

        // ####--code for create a temp. <a> html tag [link tag] for download the CSV file--####     
         var hiddenElement = document.createElement('a');
          hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
          hiddenElement.target = '_self'; // 
          hiddenElement.download = 'ExportData.csv';  // CSV file Name* [.csv extension is obligatory] 
          document.body.appendChild(hiddenElement); // Required for FireFox browser
          hiddenElement.click(); // using click() js function to download csv file
    }
   
})

project1HomeHelper.jsp
({
    convertArrayOfObjectsToCSV : function(component,objectRecords){
        // declare variables
        var csvStringResult, counter, keys, columnDivider, lineDivider,parentKey;
        // check if "objectRecords" parameter is null, then return from function
        if (objectRecords == null || !objectRecords.length) {
            return null;
         } 
        // store ,[comma] in columnDivider variable for sparate CSV values and 
        // for start next line use '\n' [new line] in lineDivider variable  
        columnDivider = ',';
        lineDivider =  '\n';

        // in the keys valirable store fields API Names as a key 
        // this labels use in CSV file header
        keys = ['Id','Parent','Parent','SobjectType','PermissionsCreate', 'PermissionsRead', 'PermissionsEdit', 'PermissionsDelete', 'PermissionsModifyAllRecords', 'PermissionsViewAllRecords' ];
        
        parentKey=['Id'];//parentKey=['AccountNumber'];

        csvStringResult = '';
        csvStringResult += keys.join(columnDivider);/* space header information here*/
        csvStringResult += lineDivider;

        for(var i=0; i < objectRecords.length; i++){   
            counter = 0;

             for(var sTempkey in keys) {
                 var skey = keys[sTempkey] ;
                 
                 // add , [comma] after every String value,. [except first]
                 if(counter > 0){
                     csvStringResult += columnDivider;
                 }
                 //csvStringResult += '"'+ objectRecords[i][skey]+'"';
                 if(typeof objectRecords[i][skey] === 'object'){
                     csvStringResult += '"'+ objectRecords[i][skey].Name+'"';
                 }else{
                     csvStringResult += '"'+ objectRecords[i][skey]+'"';
                 }
                
               counter++;

             } // inner for loop close     
             csvStringResult += lineDivider;
          }// outer main for loop close 

       // return the CSV formate String 
        return csvStringResult;        
    },
})

project1Header.cmp
<aura:component >
    <!-- PAGE HEADER -->
    <lightning:layout class="slds-page-header slds-page-header--object-home">
        <lightning:layoutItem>
            <lightning:icon iconName="action:goal" alternativeText="Generate metadata"/>
        </lightning:layoutItem>
        <lightning:layoutItem padding="horizontal-small">
            <div class="page-section page-header">
                <h1 class="slds-text-heading--label">Get out metadata</h1>
                <h2 class="slds-text-heading--medium">Get out my metadata</h2>
            </div>
        </lightning:layoutItem>
    </lightning:layout>
    <!-- / PAGE HEADER -->
</aura:component>

GenerateCSV.apxc
public Class GenerateCSV {
    @AuraEnabled
    public static List<ObjectPermissions> getObjectPermissions() {
        return [SELECT Id, Parent.Name, Parent.Profile.Name, SobjectType, PermissionsCreate, PermissionsRead, 
                PermissionsEdit, PermissionsDelete, PermissionsModifyAllRecords, PermissionsViewAllRecords 
                FROM ObjectPermissions
                ORDER BY Parent.Name, SObjectType];
                //ORDER BY Parent.Profile.Name, SObjectType];
    }
}
I can create a project on my Visual Studio Code editor due to my salesforce CLI installation. When i try verifying it version on the prompt i have this issue:
C:\Users\NOUPIK>sfdx plugins --core
 !    autoupdate:: C:\Users\NOUPIK\AppData\Local\sfdx\update.lock.readers.lock
 !    is locked
 !    C:\Users\NOUPIK\AppData\Local\sfdx\update.lock.readers.lock is locked

How can i solve it? 
Hi all,
I have this problem when creating a salesforce project on Visual Studio Code.
"Starting SFDX: Create Project
09:05:21.882 sfdx force:project:create --projectname HelloWorldLightningWebComponent --outputdir c:\Users\NOUPIK\Documents\Salesforce
! autoupdate:: C:\Users\NOUPIK\AppData\Local\sfdx\update.lock.readers.lock
! is locked
! C:\Users\NOUPIK\AppData\Local\sfdx\update.lock.readers.lock is locked
09:07:40.290 sfdx force:project:create --projectname HelloWorldLightningWebComponent --outputdir c:\Users\NOUPIK\Documents\Salesforce ended with exit code 1
"

Please i just follow the step on the Create a Hello World Lightning Web Component unit and select "SFDX: Create Project" command on VS Code after install salesforce extension pack corretly. But it look like the project  was not created. What is wrong?
Hi !
I want to get for each SObjet the Profil Name, PermissionRead, PermissionWrite, PermissionEdit via Apex.
I tried this :
SELECT O.SobjectType, O.PermissionsRead, PermissionWrite, PermissionEdit,  P.ProfileId, P.Profile.Name
FROM ObjectPermissions O, PermissionSet P
WHERE ( P.Id = O.ParentId) AND (O.SobjectType = 'Account')

But it does'nt work !

Can anyone help me?

Thanks

Hardy
This task, creating a Static Resource from:
Download the current version of the jQuery Mobile JavaScript library, currently jQuery Mobile 1.4.4, in the ZIP format.
The newest version, 1.4.5 is 7MB and of course does not upload.