• Сергей Жугин 7
  • NEWBIE
  • 45 Points
  • Member since 2018

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 12
    Replies
Hello,

I am having issue getting 100% code coverage on the following function:

@AuraEnabled
    public static string grabDetails(){
        User toReturn = [SELECT Id, ContactId,FirstName, LastName FROM User WHERE Id = :UserInfo.getUserId() LIMIT 1];
        Contact communityContact = [Select id,AccountId from contact where id = :toReturn.ContactId];
        // DML operation to save account Details
        Account a = [Select id,name,phone,website,billingStreet,billingCity,billingState,billingpostalcode,billingcountry,FEIN__c,
                     BusinessOrganization__c, progress__c from Account where id =:communityContact.AccountId];
        
        // DML operation to save account Details
        AttachmentStatus ss = new AttachmentStatus();
        
        try
        {
            List<attachment> attchs =[SELECT name FROM Attachment WHERE ParentID=: a.id]; 
            
            for(Attachment at : attchs)
            {
                if(at.name.contains('Contract'))
                {
                    ss.doesRequired1Exist = true;
                    ss.attachment1 = at.name;
                }
                else  if(at.name.contains('Liability'))
                {
                    ss.doesRequired2Exist = true;
                    ss.attachment2 = at.name;
                }
                
            }
            ss.SetDefaults();
        }
        catch(exception e){}
        
        ss.CustomerAccount = a;
        System.debug(a);
        return JSON.serializePretty(ss);
        
    }

Here is my test class thus far:

static testmethod void grabDetailsTest()
    {
        Profile p=[select id from profile where name='Contracting Owner'];
        User toReturn = new User(alias='test123', email='test123@noemail.com',
            emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
            localesidkey='en_US', profileid = p.Id, country='United States',
            timezonesidkey='America/Los_Angeles', username='test123@noemail.com');
        
        Contact c= new Contact(LastName='Test');
        
        String pdfContent = 'This is a test string';
        Account a = new Account(Name='Contract',billingStreet='123 Test Street',billingCity='Springfield',billingpostalcode='12345',billingcountry='US',FEIN__c='123456');
        insert a;
               
        
           Attachment attachmentPDF = new Attachment();
        attachmentPdf.parentId = a.id;
        attachmentPdf.name = a.name + '.pdf';
        attachmentPdf.body = blob.toPDF(pdfContent);
        insert attachmentPDF;
        
        test.startTest();
        
        SaveUpdateAccountDetails.grabDetails();
        
        test.stopTest();
    }

I would really appreciate any help that can be provided on this, thank you in advance.
Hi everyone. I need to create table in which i can selected records with checkboxes with pagination(NOTE: when i click next page records which have been selected should contain in any place and when i click final button they will sent to apex class). This table should work in LWC. P.S. If you have any question please aks me.
Hi everyone. I work with small project and ran into a problem. I need to display the most popular genre of the song in the mix object and the second after it, how can I do it using the main syntax of SOQL. If you give SOQL code or example it would be cool.
User-added image
How to connect salesfoce app and repository with GitLab API? Please give me http rest examples.
Ok, I have trouble with my component. Look at this image:
User-added image
I press 9
User-added image
I used lightning:input with with iteration. Please help me to fix this problem. Is my component code:
<aura:component controller="MyObjController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
    <aura:handler name="init" value="{!this}" action="{!c.fetchListOfRecordTypes}"/>
    
    <aura:attribute name="lstOfRecordType" type="String[]" default="1"/>

    <aura:attribute name="str" type="String[]"/>
    <aura:attribute name="InputSensor" type="Sensor__c"/>
	<aura:attribute name="SensorEvent" type="Sensor_Event__c[]"/>
    
    <aura:attribute name="isOpen" type="boolean" default="false"/>
    <div class="slds-modal__container">
        <div class="slds-page-header">
          <div class="slds-grid">
            <div class="slds-col slds-has-flexi-truncate">
              <p class="slds-text-title_caps slds-line-height_reset">My application</p>
              <h1 class="slds-page-header__title slds-m-right_small slds-align-middle slds-truncate"  title="My Contacts">Smart Work Space</h1>
            </div>
          </div>
        </div> 
    	<div class="slds-modal__content slds-p-around--medium">
                    <div class="slds-grid slds-wrap">
                        <div class="slds-size--1-of-2 slds-large-size--1-of-2">
                             <div class="slds-align--absolute-center">Select a Sensor</div>                            
                        </div>
                        <div class="slds-size--1-of-2 slds-large-size--1-of-2">
                            <ui:inputSelect aura:id="selectid">
                                <aura:iteration items="{!v.lstOfRecordType}" var="contact">                            
                                    <ui:inputSelectOption text="{!contact}" label="{!contact}"  />
                                </aura:iteration>
                            </ui:inputSelect>
                            
                            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
                            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
                            <lightning:button class="slds-button slds-button--brand" onclick="{!c.createRecord}">View records</lightning:button>
                        </div>
                        
                    </div>                   
        
        	
        </div>
        <aura:if isTrue="{!v.isOpen}">
            <table class="slds-table slds-table_bordered slds-table_cell-buffer">
                <thead>
                    <tr class="slds-text-title_caps">
                        <th scope="col">
                            <div class="slds-truncate">Name</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate">Max Vectors Difference</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate">X</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate">Y</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate">Z</div>
                        </th>
                    </tr>
                </thead>
                
                <tbody  >
            <aura:iteration items="{!v.SensorEvent}" var="item">
                
                        <tr>
                           
                            <th scope = "row">
                                <div class = "slds-truncate">{!item.Max_Vectors_Difference__c}</div>
                            </th>
                            <td>
                                <div class = "slds-truncate">{!item.Name}</div>
                            </td>
                            
                            <td>
                                <div class = "slds-truncate"><lightning:input aura:id="selectid1" value="{!item.x__c}"></lightning:input></div>
                            </td>
                            <td>
                                <div class = "slds-truncate"><lightning:input aura:id="selectid2" value="{!item.x__c}"></lightning:input></div>
                            </td>
                            <td>
                                <div class = "slds-truncate"><lightning:input aura:id="selectid3" value="{!item.x__c}"></lightning:input></div>
                            </td>

                        </tr>
                </aura:iteration>

                	<tr>
                           
                            <th scope = "row">
                                <div class = "slds-truncate"></div>
                            </th>
                            <td>
                                <div class = "slds-truncate"></div>
                            </td>
                            <td>
                                <div class = "slds-truncate"></div>
                            </td>
                            <td>
                                <div class = "slds-truncate"></div>
                            </td>
                            <td>
                                <div class = "slds-truncate"><lightning:button class="slds-button slds-button--brand" onclick="{!c.updateRecord}">Update</lightning:button></div>
                            </td>

                        </tr>

                    </tbody>
            </table>
 		</aura:if>   
    </div>
</aura:component>

 
Hi, I began to study lightning and I wanted to write a small application. My application is based on two custom object Sensor and Sensor_Event which are connected with Master detail ralationship. In my component i have 9 <lightning:input> filds and a button. In these fields I enter records of Sensor or rather Sensor__c.Sensor_Events__r[0].x__c. How to collect all these fields and pass in Apex Controller in the form of parameters of Apex function? Please give me code examples

 
Hi everyone, I'm started to learn Lightning and recently faced one problem. I want to create a trivial application. My application has one picklist and one button. I select records in the picklist and output it with the button. But it does not work. 
Please help me solve this problem.
Component:
<aura:component controller="MyObjController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
    <aura:handler name="init" value="{!this}" action="{!c.fetchListOfRecordTypes}"/>
    <aura:attribute name="lstOfRecordType" type="String[]"/>
	<aura:attribute name="atrOgj" type="Sensor__c"/>
    <aura:attribute name="isOpen" type="boolean" default="false"/>
    <div class="slds-modal__container">
    	<div class="slds-modal__content slds-p-around--medium">
                    <div class="slds-grid slds-wrap">
                        <div class="slds-size--1-of-2 slds-large-size--1-of-2">
                             <div class="slds-align--absolute-center">Select a Record Type</div>                            
                        </div>
                        <div class="slds-size--1-of-2 slds-large-size--1-of-2">
                            <ui:inputSelect aura:id="selectid">
                                <aura:iteration items="{!v.lstOfRecordType}" var="contact">                            
                                    <ui:inputSelectOption text="{!contact}" label="{!contact}"  />
                                </aura:iteration>
                            </ui:inputSelect>
                        </div>&nbsp; &nbsp;
                    </div>                   
        </div>
        <div class="slds-modal__footer">
        	<lightning:button class="slds-button slds-button--brand" onclick="{!c.createRecord}">Next</lightning:button>
        </div>
        <aura:if isTrue="{!v.isOpen}">
              
					{!atrOgj.Name}
        </aura:if>
        
       
    </div>
</aura:component>
Controller:
({
    fetchListOfRecordTypes: function(component, event, helper) {
      var action = component.get("c.fetchRecordTypeValues");
      action.setCallback(this, function(response) {
         component.set("v.lstOfRecordType", response.getReturnValue());
      });
      $A.enqueueAction(action);
   },
    
    
    createRecord: function(component, event, helper) { 
      
      var action1 = component.get("c.getRecTypeId");
      var recordTypeLabel = component.find("selectid").get("v.value");
      action1.setParams({
         "recordTypeLabel": recordTypeLabel
      });
        alert(recordTypeLabel);
      action1.setCallback(this, function(response) {
         	var state = response.getState();
          if (state === "SUCCESS")  {
             component.set('v.atrOgj', response.getReturnValue());   
             component.set("v.isOpen", true);
          }
          else {alert('Error');}
      });
      $A.enqueueAction(action1);
   }
})
Apex class:
public with sharing class MyObjController {
    public static Map<Id, String> recordtypemap {get;set;}
    
   @AuraEnabled        
    public static List<String> fetchRecordTypeValues(){
       	List<Sensor__c> recordtypes = [SELECT ID,Name FROM Sensor__c];    
        recordtypemap = new Map<Id, String>();
        for(Sensor__c rt : recordtypes){
            recordtypemap.put(rt.Id, rt.Name);
        }
        system.debug(recordtypemap.values());
        return recordtypemap.values();
    }  
        @AuraEnabled
    public static Sensor__c getRecTypeId(String recordTypeLabel){
        return [SELECT Max_Vectors_Difference__c FROM Sensor__c WHERE Name =:recordTypeLabel Limit 1];
    }
}



 
Hi All,

i have masterdetail relationship between quotes(parent) and quotelineitems(child)

and 

i also have lookup relationship between product(parent) and quotelineitems(child)

NOTE:there is no direct relationship between quotes and the product

REQUIREMENT:now i want to update a field in quotes object based on some condition in products object using Apex Trigger.

can anyone please let me know how can i proceed with this?
your help is much appreciated!
Hello,

I am having issue getting 100% code coverage on the following function:

@AuraEnabled
    public static string grabDetails(){
        User toReturn = [SELECT Id, ContactId,FirstName, LastName FROM User WHERE Id = :UserInfo.getUserId() LIMIT 1];
        Contact communityContact = [Select id,AccountId from contact where id = :toReturn.ContactId];
        // DML operation to save account Details
        Account a = [Select id,name,phone,website,billingStreet,billingCity,billingState,billingpostalcode,billingcountry,FEIN__c,
                     BusinessOrganization__c, progress__c from Account where id =:communityContact.AccountId];
        
        // DML operation to save account Details
        AttachmentStatus ss = new AttachmentStatus();
        
        try
        {
            List<attachment> attchs =[SELECT name FROM Attachment WHERE ParentID=: a.id]; 
            
            for(Attachment at : attchs)
            {
                if(at.name.contains('Contract'))
                {
                    ss.doesRequired1Exist = true;
                    ss.attachment1 = at.name;
                }
                else  if(at.name.contains('Liability'))
                {
                    ss.doesRequired2Exist = true;
                    ss.attachment2 = at.name;
                }
                
            }
            ss.SetDefaults();
        }
        catch(exception e){}
        
        ss.CustomerAccount = a;
        System.debug(a);
        return JSON.serializePretty(ss);
        
    }

Here is my test class thus far:

static testmethod void grabDetailsTest()
    {
        Profile p=[select id from profile where name='Contracting Owner'];
        User toReturn = new User(alias='test123', email='test123@noemail.com',
            emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
            localesidkey='en_US', profileid = p.Id, country='United States',
            timezonesidkey='America/Los_Angeles', username='test123@noemail.com');
        
        Contact c= new Contact(LastName='Test');
        
        String pdfContent = 'This is a test string';
        Account a = new Account(Name='Contract',billingStreet='123 Test Street',billingCity='Springfield',billingpostalcode='12345',billingcountry='US',FEIN__c='123456');
        insert a;
               
        
           Attachment attachmentPDF = new Attachment();
        attachmentPdf.parentId = a.id;
        attachmentPdf.name = a.name + '.pdf';
        attachmentPdf.body = blob.toPDF(pdfContent);
        insert attachmentPDF;
        
        test.startTest();
        
        SaveUpdateAccountDetails.grabDetails();
        
        test.stopTest();
    }

I would really appreciate any help that can be provided on this, thank you in advance.
Hi everyone. I work with small project and ran into a problem. I need to display the most popular genre of the song in the mix object and the second after it, how can I do it using the main syntax of SOQL. If you give SOQL code or example it would be cool.
User-added image
Ok, I have trouble with my component. Look at this image:
User-added image
I press 9
User-added image
I used lightning:input with with iteration. Please help me to fix this problem. Is my component code:
<aura:component controller="MyObjController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
    <aura:handler name="init" value="{!this}" action="{!c.fetchListOfRecordTypes}"/>
    
    <aura:attribute name="lstOfRecordType" type="String[]" default="1"/>

    <aura:attribute name="str" type="String[]"/>
    <aura:attribute name="InputSensor" type="Sensor__c"/>
	<aura:attribute name="SensorEvent" type="Sensor_Event__c[]"/>
    
    <aura:attribute name="isOpen" type="boolean" default="false"/>
    <div class="slds-modal__container">
        <div class="slds-page-header">
          <div class="slds-grid">
            <div class="slds-col slds-has-flexi-truncate">
              <p class="slds-text-title_caps slds-line-height_reset">My application</p>
              <h1 class="slds-page-header__title slds-m-right_small slds-align-middle slds-truncate"  title="My Contacts">Smart Work Space</h1>
            </div>
          </div>
        </div> 
    	<div class="slds-modal__content slds-p-around--medium">
                    <div class="slds-grid slds-wrap">
                        <div class="slds-size--1-of-2 slds-large-size--1-of-2">
                             <div class="slds-align--absolute-center">Select a Sensor</div>                            
                        </div>
                        <div class="slds-size--1-of-2 slds-large-size--1-of-2">
                            <ui:inputSelect aura:id="selectid">
                                <aura:iteration items="{!v.lstOfRecordType}" var="contact">                            
                                    <ui:inputSelectOption text="{!contact}" label="{!contact}"  />
                                </aura:iteration>
                            </ui:inputSelect>
                            
                            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
                            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
                            <lightning:button class="slds-button slds-button--brand" onclick="{!c.createRecord}">View records</lightning:button>
                        </div>
                        
                    </div>                   
        
        	
        </div>
        <aura:if isTrue="{!v.isOpen}">
            <table class="slds-table slds-table_bordered slds-table_cell-buffer">
                <thead>
                    <tr class="slds-text-title_caps">
                        <th scope="col">
                            <div class="slds-truncate">Name</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate">Max Vectors Difference</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate">X</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate">Y</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate">Z</div>
                        </th>
                    </tr>
                </thead>
                
                <tbody  >
            <aura:iteration items="{!v.SensorEvent}" var="item">
                
                        <tr>
                           
                            <th scope = "row">
                                <div class = "slds-truncate">{!item.Max_Vectors_Difference__c}</div>
                            </th>
                            <td>
                                <div class = "slds-truncate">{!item.Name}</div>
                            </td>
                            
                            <td>
                                <div class = "slds-truncate"><lightning:input aura:id="selectid1" value="{!item.x__c}"></lightning:input></div>
                            </td>
                            <td>
                                <div class = "slds-truncate"><lightning:input aura:id="selectid2" value="{!item.x__c}"></lightning:input></div>
                            </td>
                            <td>
                                <div class = "slds-truncate"><lightning:input aura:id="selectid3" value="{!item.x__c}"></lightning:input></div>
                            </td>

                        </tr>
                </aura:iteration>

                	<tr>
                           
                            <th scope = "row">
                                <div class = "slds-truncate"></div>
                            </th>
                            <td>
                                <div class = "slds-truncate"></div>
                            </td>
                            <td>
                                <div class = "slds-truncate"></div>
                            </td>
                            <td>
                                <div class = "slds-truncate"></div>
                            </td>
                            <td>
                                <div class = "slds-truncate"><lightning:button class="slds-button slds-button--brand" onclick="{!c.updateRecord}">Update</lightning:button></div>
                            </td>

                        </tr>

                    </tbody>
            </table>
 		</aura:if>   
    </div>
</aura:component>

 
Hi everyone, I'm started to learn Lightning and recently faced one problem. I want to create a trivial application. My application has one picklist and one button. I select records in the picklist and output it with the button. But it does not work. 
Please help me solve this problem.
Component:
<aura:component controller="MyObjController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
    <aura:handler name="init" value="{!this}" action="{!c.fetchListOfRecordTypes}"/>
    <aura:attribute name="lstOfRecordType" type="String[]"/>
	<aura:attribute name="atrOgj" type="Sensor__c"/>
    <aura:attribute name="isOpen" type="boolean" default="false"/>
    <div class="slds-modal__container">
    	<div class="slds-modal__content slds-p-around--medium">
                    <div class="slds-grid slds-wrap">
                        <div class="slds-size--1-of-2 slds-large-size--1-of-2">
                             <div class="slds-align--absolute-center">Select a Record Type</div>                            
                        </div>
                        <div class="slds-size--1-of-2 slds-large-size--1-of-2">
                            <ui:inputSelect aura:id="selectid">
                                <aura:iteration items="{!v.lstOfRecordType}" var="contact">                            
                                    <ui:inputSelectOption text="{!contact}" label="{!contact}"  />
                                </aura:iteration>
                            </ui:inputSelect>
                        </div>&nbsp; &nbsp;
                    </div>                   
        </div>
        <div class="slds-modal__footer">
        	<lightning:button class="slds-button slds-button--brand" onclick="{!c.createRecord}">Next</lightning:button>
        </div>
        <aura:if isTrue="{!v.isOpen}">
              
					{!atrOgj.Name}
        </aura:if>
        
       
    </div>
</aura:component>
Controller:
({
    fetchListOfRecordTypes: function(component, event, helper) {
      var action = component.get("c.fetchRecordTypeValues");
      action.setCallback(this, function(response) {
         component.set("v.lstOfRecordType", response.getReturnValue());
      });
      $A.enqueueAction(action);
   },
    
    
    createRecord: function(component, event, helper) { 
      
      var action1 = component.get("c.getRecTypeId");
      var recordTypeLabel = component.find("selectid").get("v.value");
      action1.setParams({
         "recordTypeLabel": recordTypeLabel
      });
        alert(recordTypeLabel);
      action1.setCallback(this, function(response) {
         	var state = response.getState();
          if (state === "SUCCESS")  {
             component.set('v.atrOgj', response.getReturnValue());   
             component.set("v.isOpen", true);
          }
          else {alert('Error');}
      });
      $A.enqueueAction(action1);
   }
})
Apex class:
public with sharing class MyObjController {
    public static Map<Id, String> recordtypemap {get;set;}
    
   @AuraEnabled        
    public static List<String> fetchRecordTypeValues(){
       	List<Sensor__c> recordtypes = [SELECT ID,Name FROM Sensor__c];    
        recordtypemap = new Map<Id, String>();
        for(Sensor__c rt : recordtypes){
            recordtypemap.put(rt.Id, rt.Name);
        }
        system.debug(recordtypemap.values());
        return recordtypemap.values();
    }  
        @AuraEnabled
    public static Sensor__c getRecTypeId(String recordTypeLabel){
        return [SELECT Max_Vectors_Difference__c FROM Sensor__c WHERE Name =:recordTypeLabel Limit 1];
    }
}