• Edgars Everts 5
  • NEWBIE
  • -1 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 10
    Replies
Hi,

Story about lightning:datatable 

some component lines:
attributes:
<aura:attribute name="data" type="Object"/>
<aura:attribute name="rowSource" type="Object"/>

Table definition:
<lightning:datatable
                                aura:id="linesTable"
                                keyField="Id"
                                columns="{! v.columns }"
                                data="{! v.data }"
                                errors="{! v.errors }"
                                draftValues="{! v.draftValues }"
                                selectedRows="{! v.selectedRows }"
                                showRowNumberColumn="true"
                                onrowaction="{! c.openModel }"
                                onrowselection="{! c.countRows }"
                                onsave="{! c.handleSaveEdition }"
                                 />

and modal window ( to simulate dropdown list )
with picklist values:
<lightning:select aura:id="selectedStage" label="" name="selectStage" onchange="{!c.handleStageSelected}">
                                    <option value=""> </option>


on Closing modal window with save
<lightning:button variant="brand" 
                                              label="Save"
                                              title="Save"
                                              onclick="{!c.saveSegment}"/>


controller lines:
   openModel: function(component, event, helper) {
        component.set("v.isOpen", true);
        console.log("action: openModal => row: " + event.getParam('row'));
        component.set("v.rowSource", event.getParam('row'));        
    },

console output:
action: openModal => row: [object Object]
 
saveSegment: function(component, event, helper) { 
        // and set set the "isOpen" attribute to "False for close the model Box.
        component.set("v.isOpen", false);
        var vStageName = component.get("v.selectedStage");
        var cmRow = component.get("v.rowSource");
        console.log("action: saveSegment => row: " + cmRow);
        var cmRows = component.get("v.data");
        console.log("action: saveSegment => rows: " + cmRows);
        /** This method has the same algorithm as Array.prototype.indexOf(). TypedArray is one of the typed array types here. */
        var cmRowPosition = cmRows.indexOf(cmRow);
        console.log("action: saveSegment => rowIndex: " + cmRowPosition);

        cmRows[cmRowPosition].StageName = vStageName;
        component.set("v.draftValues", cmRows);
       
   },

Console output:
action: openModal => row: [object Object]
opportunityDataTableTest.js:44 action: saveSegment => row: [object Object]
opportunityDataTableTest.js:46 action: saveSegment => rows: [object Object],[object Object],[object Object],[object Object],[object Object]
opportunityDataTableTest.js:50 action: saveSegment => rowIndex: -1
Scenario:
Load Opportunitties with lightning datatable
OnRowaction - do open Modal window, here store current Row in component variable.
On Modal window picklist value change, store picklist value in component variable
On Modal window close by Save , get Component Row and Component Table, and find the Position of Row in Table
Then idea is set Row.fieldName = to Modal Window picklist value 
And on Save Table, should Update Opportunities accordingly.

Have to admit that this "solution" works in developer edition, but have challenge to transfer code to "work-sandbox".
Copy paste 1:1, but in "work-sanbox" it doesn't work.

And page fails with the following:
This page has an error. You might just need to refresh it. Action failed: c:opportunityDataTableTest$controller$saveSegment [Cannot set property 'StageName' of undefined] Failing descriptor: {c:opportunityDataTableTest$controller$saveSegment}

Question:?
In code examples on RowActions there is variable row, which is get by event.getParam(<param>).
e.g. 
component.set("v.rowSource", event.getParam('row'));

Honestly not clear where this 'row' parameter comes from as per lightning:datatable there is no such parameter. Any ideas?

How to ensure what parameters can be used in event.getParam( ) function?

Seems that Object position cannot be found by "row" , and indexOf returns -1. / but in developer org, the "same" code works/

Any ideas how to debug this besides console.log?
Is it possible to compare the data types of row [Object] and v.data[index][Object]?

Looking forward for your advice!
Thank you in advance.

Kind regards,
​​​​​​​Edgars
Hi,
Inline Account Hierarchy was implemented in DEV environment (one of sandboxes), and adjusted a little, but due deployment to another sandbox: Test environment we are facing the deployment fail:

BUILD FAILED
/...jenkins/build.xml:95:
*********** DEPLOYMENT FAILED *********** Request ID: <ID>
All Component Failures:
1.  components/AccountHierarchyTree.component -- Warning: The element type "div" should be terminated by the matching end-tag "</div>" in AccountHierarchyTree at line 80
 
*********** DEPLOYMENT FAILED ***********

We are deploying Apex Classes:
AccountStructure
AccountHierarchyTestData
testAccountHierarchy
InlineAccountHierarchy_TestUtilities
VF Page: AccountHierarchyPage
VF Component: AccountHierarchyTree

Have tried to separate classes and vf page from component, but as they have reference to another, I could not deploy them seperately.
AccountHierarchyTree component left with API = 15, so "invalid" </div> tag work just fine in DEV environment, Account hierarchy is shown on Account detail page. Note this "div" give warning till API = 18, but since API = 19 it trows an error.

Component code:
<!--
    Copyright (c)2008, Matthew Friend, Sales Engineering, Salesforce.com Inc.
    All rights reserved. 

-->

<apex:component Controller="AccountStructure">
    <apex:attribute name="currentIdVF" description="This is the Account Id for displaying Acccount Hierarchy" type="String" required="true" assignTo="{!currentId}"/>

    <div class="treeNode">
            <apex:repeat value="{!ObjectStructure}" var="pos" >
            <apex:repeat value="{!pos.levelFlag}" var="flag" first="0">
                <apex:image url="/img/tree/empty.gif" height="16" width="20" rendered="{!IF(flag,false,true)}"/>
                <apex:image url="/s.gif" alt="" width="3" height="16" rendered="{!IF(flag,true,false)}"/>
                <apex:image url="/img/tree/chain.gif" height="16" width="20" rendered="{!IF(flag,true,false)}"/>
            </apex:repeat>

            <span height="16" v="top">

            <apex:outputText rendered="{!IF(pos.nodeType=='start',true,false)}">
                <apex:image id="tree_start" url="/img/tree/minusStart.gif" height="16" width="20" title="Click to expand/collapse nested items." onClick="TreeNodeElement.prototype.toggle(this,'{!pos.nodeId}')"/>
                <apex:image id="Icon_start" url="/img/icon/custom51_100/globe16.png" width="16" height="16" rendered="{!IF(pos.currentNode,false,true)}"/>
                <apex:image id="Icon_start_current" url="/img/icon/star16.png" width="16" height="16" rendered="{!IF(pos.currentNode,true,false)}"/>
            </apex:outputText>

....

<!-- Change Below -->
            <apex:outputLink value="/{!pos.account.id}" style="{!IF(pos.currentNode,'font-weight: bold;','')}" styleClass="columnHeadActiveBlack" target="_top">{!pos.account.name}</apex:outputLink>

...

<!-- Stop -->
            </span>
                
            <div> </div>
               
            <apex:outputText rendered="{!IF(OR(pos.nodeType=='child_end',pos.nodeType=='child'),false,true)}">
                <div id='{!pos.nodeId}'>
            </apex:outputText>
            <apex:outputText rendered="{!IF(OR(pos.nodeType=='child_end',pos.nodeType=='child'),true,false)}">
                <div id='{!pos.nodeId}'><apex:image url="/s.gif" alt="" width="1" height="1"/></div>
            </apex:outputText>
            <apex:repeat value="{!pos.closeFlag}" var="close">
                </div>               
            </apex:repeat>    
                    

    </apex:repeat>
    <br/><br/><br/>
    </div>
</apex:component>

So this component is warned because of not closed "div", but if we rewrite this part, then Account hierarchy looses it expand/collapse functionality
<apex:outputText rendered="{!IF(OR(pos.nodeType=='child_end',pos.nodeType=='child'),false,true)}">
                <div id='{!pos.nodeId}'>
            </apex:outputText>

But not sure if this component can be deployed into test environment!? Any idea, advise would be great!!!
Thank you in advance.
Hi,

Story about lightning:datatable 

some component lines:
attributes:
<aura:attribute name="data" type="Object"/>
<aura:attribute name="rowSource" type="Object"/>

Table definition:
<lightning:datatable
                                aura:id="linesTable"
                                keyField="Id"
                                columns="{! v.columns }"
                                data="{! v.data }"
                                errors="{! v.errors }"
                                draftValues="{! v.draftValues }"
                                selectedRows="{! v.selectedRows }"
                                showRowNumberColumn="true"
                                onrowaction="{! c.openModel }"
                                onrowselection="{! c.countRows }"
                                onsave="{! c.handleSaveEdition }"
                                 />

and modal window ( to simulate dropdown list )
with picklist values:
<lightning:select aura:id="selectedStage" label="" name="selectStage" onchange="{!c.handleStageSelected}">
                                    <option value=""> </option>


on Closing modal window with save
<lightning:button variant="brand" 
                                              label="Save"
                                              title="Save"
                                              onclick="{!c.saveSegment}"/>


controller lines:
   openModel: function(component, event, helper) {
        component.set("v.isOpen", true);
        console.log("action: openModal => row: " + event.getParam('row'));
        component.set("v.rowSource", event.getParam('row'));        
    },

console output:
action: openModal => row: [object Object]
 
saveSegment: function(component, event, helper) { 
        // and set set the "isOpen" attribute to "False for close the model Box.
        component.set("v.isOpen", false);
        var vStageName = component.get("v.selectedStage");
        var cmRow = component.get("v.rowSource");
        console.log("action: saveSegment => row: " + cmRow);
        var cmRows = component.get("v.data");
        console.log("action: saveSegment => rows: " + cmRows);
        /** This method has the same algorithm as Array.prototype.indexOf(). TypedArray is one of the typed array types here. */
        var cmRowPosition = cmRows.indexOf(cmRow);
        console.log("action: saveSegment => rowIndex: " + cmRowPosition);

        cmRows[cmRowPosition].StageName = vStageName;
        component.set("v.draftValues", cmRows);
       
   },

Console output:
action: openModal => row: [object Object]
opportunityDataTableTest.js:44 action: saveSegment => row: [object Object]
opportunityDataTableTest.js:46 action: saveSegment => rows: [object Object],[object Object],[object Object],[object Object],[object Object]
opportunityDataTableTest.js:50 action: saveSegment => rowIndex: -1
Scenario:
Load Opportunitties with lightning datatable
OnRowaction - do open Modal window, here store current Row in component variable.
On Modal window picklist value change, store picklist value in component variable
On Modal window close by Save , get Component Row and Component Table, and find the Position of Row in Table
Then idea is set Row.fieldName = to Modal Window picklist value 
And on Save Table, should Update Opportunities accordingly.

Have to admit that this "solution" works in developer edition, but have challenge to transfer code to "work-sandbox".
Copy paste 1:1, but in "work-sanbox" it doesn't work.

And page fails with the following:
This page has an error. You might just need to refresh it. Action failed: c:opportunityDataTableTest$controller$saveSegment [Cannot set property 'StageName' of undefined] Failing descriptor: {c:opportunityDataTableTest$controller$saveSegment}

Question:?
In code examples on RowActions there is variable row, which is get by event.getParam(<param>).
e.g. 
component.set("v.rowSource", event.getParam('row'));

Honestly not clear where this 'row' parameter comes from as per lightning:datatable there is no such parameter. Any ideas?

How to ensure what parameters can be used in event.getParam( ) function?

Seems that Object position cannot be found by "row" , and indexOf returns -1. / but in developer org, the "same" code works/

Any ideas how to debug this besides console.log?
Is it possible to compare the data types of row [Object] and v.data[index][Object]?

Looking forward for your advice!
Thank you in advance.

Kind regards,
​​​​​​​Edgars
Hi All ,
i'm trying to update a record using  "onrowaction " button in lightning datatable , when i'm passing the parameters to server side controller getting this error  "Cannot read property 'updaterecord' of undefined".

Please help me to find solutions for below querrys 
1. How to capture row id and pass to server side controller .
2. How to get the component value ( getting error 'Cannot read property 'updaterecord' of undefined')
2. Is it possible to call helper method using "onrowaction " . Below my sample code

Controller :

component.set('v.columns', [
            {label: $A.get("$Label.c.AccountName"), fieldName: 'Name', type: 'text', sortable : true},
            {label: 'Update', type: 'button', initialWidth: 135, typeAttributes: { label: 'Update', name: 'view_details', title: 'Click to View Details'}}]);

handleRowAction :function(component, event, helper){
       var action = event.getParam('action');
       var row = event.getParam('row');
       switch (action.name) {
           default:
               helper.showRowDetails(row);
               break;
       }

Helper :

showRowDetails : function(row ,component, event,helper ) {
       // var kkk = component.get("v.AccountID");
       alert("Showing opportunity " + row.Name + " closing on " + row.Id);
        helper.updaterecord(component, event,helper);
   },
    
    updaterecord : function(cmp, event,helper ) {
       var action = cmp.get("c.updaterecord"); 
      action.setParams({"focID " : cmp.get("v.kkrecordId")}); 
        action.setCallback(this, function(response) {
            var state = response.getState();
            var responseval = response.getReturnValue();

            if (cmp.isValid() && state === "SUCCESS" && responseval.isSuccess) {
                console.log(response.getReturnValue());
                   window.location.replace("/"+cmp.get("v.kkrecordId"));
            }
            else if(state == "ERROR" || !responseval.isSuccess){
                alert(responseval.message);
            }
        });

Component :

<lightning:datatable data="{! v.allacountlist}" class="slds-m-top_medium"
                             columns="{! v.columns }" 
                             keyField="id"
                             aura:id="tableid"
                             hideCheckboxColumn="true"
                             onrowaction="{! c.handleRowAction }"/>
when i write a query with limit 49997.it shows the Number of query rows: 119997 out of 50000 ******* CLOSE TO LIMIT.
I want to know how it works.
 
  • September 06, 2017
  • Like
  • 1
We have the Inline Account Hierarchy app from Salesforce labs installed. It has been installed and working fine since July 2014 and I've made several Change Set deployments since them without incident. I am now suddenly unable to deploy a Flow from our Sandbox to Production, and this application is the one that is failing the code tests. (I don't have a lot of Apex in the system, (I'm not a programmer) and what Apex I do have is all from 3rd party AppExchange apps like this one.) My code coverage has suddenly gone from something like 89% to 29%. on the AccountStructure class 0 out of 133 lines are passing, and other Classes related to this application are getting 41%, 71% and 84% coverage which is all a bit disturbing.

I haven't altered the test scripts since they were installed.
I have turned off the two validation rules that were running against the account object.
I have added a couple of new custom account fields, but they do not have validation statements in them.
I have added one rollup field recently that counts the number of opportunities on the account. 

Since I have no experience in writing test cases, and have never had to deal with code coverage issues before:

Are there other things I should check?
Are there resources I can reference to learn more?
Does anyone have any ideas on how to fix this?

I don't want to have to delete the application because one of our business units relies on it, but it may come to that if I can't deploy things to production!

Specific errors I encounter are:

Class.InlineAcountHerachy_TestUtilities.updateAccountList: line 106, column 1
Class.AccountHierarchyTestData.createTestHierarchy: line 33, column 1
Class.testAccountHierarchy.testAccountHierarchy: line 6, column 1

First error code near error "106, column 1"
101       if ( this.checkObjectCrud('Account', fieldsToCheck, 'create') && !this.testAccList.isEmpty() ){
102         try{
103           update this.testAccList;
104         }
105         catch( Exception ex ){
106          System.assert( false ,'Pre deploy test failed, This may be because of custom validation rules in your Org. You can check ignore apex errors or temporarily deactivate your validation rules for Accounts and try again.');
107        }
108       }
109       else{
110         System.Assert(false , 'You need right over Account Object');
111       }

Second error at line 33, column 1

26         // Create 10 sub accounts
27       testUtils.createAccounts( 10 , fieldsToCheck );
28       Integer i = 0;
29         for ( Account accAux : testUtils.testAccList ){ //Now i need change the names
30           accAux.Name = 'HierarchyTest' + String.valueOf( i );
31             i++;
32         }
33         testUtils.updateAccountList( fieldsToCheck );        
34         
35         List<Account> accountList = [ Select Id, parentID, name from account where name like 'HierarchyTest%' ORDER BY Name limit 10 ];
36                 
37         for ( Integer x = 0; x < accountList.size(); x++ ){
38             if ( accountList[x].name != 'HierarchyTest0' ){
39                 accountList[x].parentID = parentID;
40                 parentID = accountList[x].Id; 
41             }

Last error at line 6, column 1
1 @isTest
2 private class testAccountHierarchy{
3
4     static testMethod void testAccountHierarchy(){
5
6         AccountHierarchyTestData.createTestHierarchy();
7
8         Account topAccount      = [ Select id, name from account where name = 'HierarchyTest0' limit 1 ];
9         Account middleAccount   = [ Select id, parentID, name from account where name = 'HierarchyTest4' limit 1 ];
10         Account bottomAccount   = [ Select id, parentID, name from account where name = 'HierarchyTest9' limit 1 ];
11         Account[] accountList   = [ Select id, parentID, name from account where name like 'HierarchyTest%' ];
12
13         test.startTest();

Any guidance will be greatly appreciated.
 
Hi guys, 

 I want to enable API but don't find option to enable API in my trial account.

please tell me can i enable api to trial account.

input text fields on VF page do not seem to have autofill turned on (feature where browser "remembers" the last input on the form and provides suggestions). I also tried to provide the value "on" to "autocomplete" attribute on the input feilds via js but that didnt work. I read on a forum that autocomplete attribute needs to be turned "on" at the form level but that didnt help either. 

 

Any help would be appreciated! Thanks

I wrote a test class that passed without issue in one sandbox environment (test), but fails in the next environment (UAT).  I did a file compare on the affected class and the test class and found no differences.  It fails on the insert call:

 

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Last Modified Date(Mon Jul 26 01:48:35 GMT 2010) before Create Date(Mon Jul 26 01:48:37 GMT 2010).: [LastModifiedDate]

 

I found reference to this type of error in the data migration area, but not in Apex code.  Any ideas as to what may cause this?

 

Thanks,

 

Brian