• Rein Bauwens 37
  • NEWBIE
  • 5 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
I need to remove the 1st column from the lightning table which is the row number but not able to do it.
User-added image


My .cmp looks as follows
 
<aura:attribute name="recordId" type="Id" />
<aura:attribute name="Order" type="Order__c" />
<aura:attribute name="OrderLines" type="Otter_FFA_Order_Line_Item__c" />
<aura:attribute name="Columns" type="List" />

<aura:handler name="init" value="{!this}" action="{!c.myAction}" />

<force:recordData aura:id="OrderRecord" recordId="{!v.recordId}" targetFields="{!v.Order}" layoutType="FULL" />


<lightning:card iconName="standard:contact" title="{! 'Order Items List for ' + v.Order.Otter_FFA_Order__c}">
    <!-- Order Line list goes here -->
        <lightning:datatable data="{! v.OrderLines }" columns="{! v.Columns }"  keyField="Id"/>

</lightning:card>

And .js is as below
({ myAction : function(component, event, helper) {

    component.set("v.Columns", [
        {label:"#", initialWidth: 20, fieldName:"Otter_FFA_Ln__c", type:"number"},
        {label:"Item", initialWidth:80, fieldName:"Product_Name__c", type:"text"},
        {label:"Description", initialWidth: 110, fieldName:"Description_1_and_2__c", type:"text"},
        {label:"QTY", initialWidth: 70, fieldName:"Otter_FFA_Quantity__c", type:"number",editable: true},
    {label:"Net Price", initialWidth: 70, fieldName:"Otter_FFA_Net_Price__c", type:"number"},
        {label:"Add Disc%", initialWidth: 90, fieldName:"Otter_FFA_User_Discount__c", type:"number",editable: true},
        {label:"Order Price", initialWidth: 70, fieldName:"Otter_FFA_Applied_Net_Price__c", type:"number",editable: true},
        {label:"Total Before GST", initialWidth: 70, fieldName:"Otter_FFA_Total_Price__c", type:"number"}

    ]);
    var action = component.get("c.getOrderLines");

    action.setParams({
        recordId: component.get("v.recordId")
    });

    action.setCallback(this, function(OrderLines) {
        component.set("v.OrderLines", OrderLines.getReturnValue());
    });

    $A.enqueueAction(action);
}
})

with a stylesheet as below
.THIS .slds-th__action{ word-wrap: initial; font-weight: bold; font-size: 70% !important; }
 
We are using Communities with Salesforce and to make Contact/User management easier, I've written a trigger that marks the User record as Inactive when the Contact record is marked Inactive using a custom field called Inactive__c.  The trigger works great.  I'm trying to write test code coverage that covers the following scenario:

1) Create an Account
2) Create a Contact
3) Promote the Contact to a User
4) Mark the Contact as Inactive

My Test Class is below.  The problem I'm running into is I don't know how to simulate selecting the "Manage External User" button on a Contact and Enabling the Contact for a Community. 

I originally tried inserting a User record directly, but you can't insert an ID into the Contact ID field.  I then tried to use the Site.CreatePortalUser() method hoping it was used in Communities, but it's not doing anything (as far as I can tell because the debug is coming back null). 

Does anybody have experience with Communities and linking the Contact to the User through Apex and Test classes?  My current test class is below.
@istest
public class pdi_InactiveUserTest {
    
    public static testMethod void pdi_InactiveUserTest() {
        
         // Create an account
        Account acct = new Account(name='Test Company');
        insert acct;
        
        // Add a Contact to the account
        Contact mycontact = new Contact(FirstName='Test',LastName='User',Email='TestUser@email.com');
        insert mycontact;

        //Create a User Record off of Contact (trying Portal method)        
        User u = new User();
        u.Username = mycontact.email;
        u.Email = mycontact.email;
        u.contactid = mycontact.id;
        u.communitynickname = 'testuser';   
        
        string accountid = acct.id;
        string password = null;
        
        string userid = site.createportaluser(u, accountid, password);
        system.debug(userid);
        
        //Update the Contact and make it inactive.
        mycontact.Inactive__c = true;
        update mycontact;
        
    }
}