• Henrique Rodrigues
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 4
    Questions
  • 0
    Replies
Hi experts, i'm trying to develop a trigger that send an email when a record is created with a condition, but when I insert the record in the object i'm not receive the email.

This is my code: 
trigger Fila on Fila__c (before insert) {

	 	
    	List<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();
  
    	for(Fila__c fila : Trigger.New) {
            
            if(fila.Posicao__c == 2){
            Messaging.SingleEmailMessage mail =  new Messaging.SingleEmailMessage();
	  		//  list of people who should get the email
          	List<String> sendTo = new List<String>();
          
          	sendTo.add('henriquelive19@gmail.com');
          	mail.setToAddresses(sendTo);
        
          	// Set email is sent from
          	mail.setReplyTo('henrique@mobiaplicativos.com.br');
          	mail.setSenderDisplayName('henrique');
        
          	// Set email contents
          	mail.setSubject('URGENT BUSINESS PROPOSAL');
          	String body = 'Dear ';
          	body += 'Email Body.';
          
          	mail.setHtmlBody(body);
        
          	// Add your email to the master list
          	mails.add(mail);
            
            try
             {
               Messaging.sendEmail(mails);	
             }
            catch (Exception e) {
               System.debug('erro' + e);
             }
      	}
  	}
}

my test class is working, but the trigger are not working, anybody can help me in this case?
Hello everyone, i'm developing a webservice in rest and i have no ideia about how write a test class in this case and this is my code
@RestResource(urlMapping='/upsertaccount')
global with sharing class WSCustomerEdit {
   
   @HttpPost
    global static Account doPost(){
        String accountJSON = RestContext.request.requestBody.toString();
        JsonAccount serializedAcc = (JsonAccount)(JSON.deserialize(accountJSON, JsonAccount.class));
    
        Account acc = [SELECT Id FROM Account WHERE id =: serializedAcc.Id];
        acc.Name = serializedAcc.name;
        acc.Phone = serializedAcc.phone;
        upsert acc;
        return acc;
        
    }

    global class JsonAccount{
        public String id      {get;set;}
        public String name    {get;set;}
        public String phone   {get;set;}
        public String address {get;set;}
    }
}
and my test class
@isTest
public class CustomerEditTest {

  @isTest
	static void teste(){
        
		WSCustomerEdit.JsonAccount acc = new WSCustomerEdit.JsonAccount();
        
		acc.id      = 'test';
		acc.name    = 'NameTest';
		acc.phone   = '1198785496';
		acc.address = 'Rua x';

		String myJSON = JSON.serialize(acc);
	}
}

how can I make a test class with 100% of code coverage? 
 
Hello everyone, i'm coding a test class and I have a 'insert' in the account object that have a RecortType, how can I reference the Record Type to insert?

The error is: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field: Warehouse: [Type2__c]
 
Account ac = new Account();
        ac.Name = 'Account';
        ac.Type2__c = 'Warehouse';
        ac.Country2__c = ct.Id;
        ac.City__c = city.Id;
        ac.Oracle_Code__c = '1';
        
        insert ac;


 
Hello, i'm developing a web service to receive a list from a third-party software, but when my class receive the list, nothing happens. How can i insert records with this way in salesforce? This is my code, can anyone evaluate to see what is wrong, please?
 
global class IntegrationWSCustomerItem {
    
    global class CustomerItemResponse {
         webservice String Oracle_Code;
         webservice Id Salesforce_ID; 
         webservice Boolean Status;
         webservice String Description;
    }
    global class CustomerItemRequest {
        webservice String Account_Code;
        webservice String Application_Code;
        webservice String Code_Product_Customer;
        webservice String Oracle_Code;
        webservice String Product_Code;
        webservice String Subsegment_Code;
        
    }
    
    webservice static List<CustomerItemResponse> createCustomerItem(List<CustomerItemRequest> customer_entrada){
        
        IntegrationUtils.WSLog('Customer_Item', JSON.serialize(customer_entrada));
        List<CustomerItemResponse> Result = new List<CustomerItemResponse>();
        List<Customer_Item__c> Customer_Item = new List<Customer_Item__c>();
        //List<CustomerItemRequest> cir = new List<CustomerItemRequest>();
        
        
        
       for (CustomerItemRequest cir : customer_entrada) {
           Customer_Item__c ci = new Customer_Item__c();
          	ci.Account__c = cir.Account_Code;
            ci.Application__c = cir.Application_Code;
            ci.Code_Product_Customer__c = cir.Code_Product_Customer;
            ci.Oracle_Code__c = cir.Oracle_Code;
            ci.Product__c = cir.Product_Code;
            ci.Subsegment__c = cir.Subsegment_Code;
         	Customer_Item.add(ci);   
        }
       
		return new List<CustomerItemResponse>();
        
    }
    
}

 

Hi

I have in my Org a custom object called Documento__c, where I only fill some fields and attach a file on its records.
I have a partner community too, where the community users shoud see these Documento__c records, and all the attachments.

The problem is, the portal users cannot see the attachments, unless the user be the attachment owner.

I know there are two kinds os "Attachments" that can be used in these "Notes and Attachments" related lists:
 - Attachment: That is directly related with the parent record, and nothing else.
 - File: That is a user file, witch is shared with the record at the moment it's uploaded. In this case I can see this file in the "Files" tab, and share with other records, groups and libraries too.
In both cases, they apear in the "Notes and Attachments" related lists.

With "Attachment" Attachs, everyone can see them, but everytime someone upload a file in these Attachments lists, it goes as a "File" instead "Attachment"
I know there is a option in the Org settings that changes this behavor, but it seems just works with non lightning layouts, which is not my case, and furthermore there are lots of "files" alread attached at this lists that wont be affected with this change.

User-added image

I already tried to create a libary, to add the portal users on it, then to attach the "file" and share the attached file with the libary.
When a do it, the portal users can see the file only at the "Files" tab, inside the libary.. but the "Notes and Attachments" related lists continue not showing the attachment file.

Follows an example, to better undertanding..

A internal user named "Desenvolvimento" attached 2 files:
 - "teste" was uploaded as a "File"
 - "teste 2" was uploaded as a "Attachment"

User-added image

Then the user created a libary called "Comunidade"(1), added the partner users (2), and shared the "test" file with it:

User-added image

The patner user logged in the community, opens the "File" tab and sees the file there:

User-added image

But in the record related list, it does not apear.. only the "Attachment" apears.

User-added image

Some sugestion how can this Files be displayed in the Attachments related lists to the partner community users?

Thanks!