• Rafael.Martins.Santos
  • NEWBIE
  • 140 Points
  • Member since 2016
  • Developer
  • ServiceIT

  • Chatter
    Feed
  • 1
    Best Answers
  • 2
    Likes Received
  • 1
    Likes Given
  • 36
    Questions
  • 102
    Replies
In below code am getting , am trying so many different method sample lot is parent and sample transaction is child could you please suggets me what is the reason for below error
Compile Error: Didn't understand relationship 'Sample_Transaction__c' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 8 column 44

 
trigger quantityleft on Sample_Transaction__c (after insert,after update,after delete,after undelete) {
    List<Sample_Lot__c> list_Account= new List<Sample_Lot__c>();
     set<Id> set_Opportunity = new set<Id>();
         for(Sample_Transaction__c objOpp: trigger.new){
        set_Opportunity.add(objOpp.Sample_Lot_ID__c);
    }
    Decimal Sum;
            for(Sample_Lot__c objAccount : [SELECT Id,(SELECT Id,sample_lot FROM Sample_Transaction__c),Quantity_Left__c FROM Sample_Lot__c WHERE Id IN: set_Opportunity]){
        Sum=0;
                        
        for(Sample_Transaction__c objOpp01: objAccount.Quantity_Left__c){
            Sum+=objOpp01.Confirmed_Quantity__c ;
        }
        objAccount.Quantity_left__c =Sum;
        list_Account.add(objAccount);
    }
    update list_Account;
}

 
Hi,

When I tried to publish my code  to production this error occurs in validation time.

Internal Salesforce Error: 1676106529-3497 (77818351) (77818351) Stack Trace: null

My code assign automatically the user to a public group.

Someone knows this error? And how I fix this?

Best Regards
Rafael
Hi,

I have a custom object child of the opportunity object.
I want make a SOQL from the child to get the data of the Opportunity.
Someone know how I do that?
Some best practice in this case.

Thanks

Rafael
Hi
I have a child object classed OpportunityItem__c that the parent is Opportunity, and in the OpportunityItem__ I have a relationship field that get the Id from an Object called Goal__c.

In the OpportunityItem__c I have a trigger, in these trigger I have to get the Opportunity Id and get the Goal Id too.

My code is like this:

for(OpportunityItem__c item : trigger.new)
{
opportunityId = item.OpportunityId; //(relationship field Name in OpportunityItem__c)
year = item.CloseDate__c;
}
  list<Goal__c> goalsList = [SELECT Id, Year__c FROM Goal__c WHERE Year__c =: year];
  list<Opportunity> opportunities = [SELECT Id, Name FROM Opportunity WHERE Id=: opportunityId ];

Until here ok.
But When I test, both list get a exception of SOQL Limit 101.
I want some manner to get the data of Goal and Opportunity that have relationship with the current item that fire a trigger.

Someone knows how I do that?

Best Regards
Rafael
Hi,
I developed a trigger that automatize the process of assigment of users in public groups, and I created the test class too, but occurs an error of DML and Query.

Hete is the trigger code.
trigger User_Public_Group on User (before insert, before update) {
    
    if(trigger.isBefore){
        GroupMember publicGroup = new GroupMember();
        if(trigger.isInsert){
           for(User u : trigger.new){
               if(u.ProfileId == '00e16000001GkRp' || u.ProfileId == '00e16000001GkRk' || u.ProfileId == '00e16000001GkS4'){
                    publicGroup.GroupId = '00GA0000000U7Cs';
                    publicGroup.UserOrGroupId = u.Id;
                    Database.insert(publicGroup);
               }else if(u.ProfileId == '00e16000001GkRf' || u.ProfileId == '00e16000001GkKU' || u.ProfileId == '00e16000001GkRz'){
                   publicGroup.GroupId = '00G16000005ReMc';
                   publicGroup.UserOrGroupId = u.Id;
                   Database.insert(publicGroup);
               }
           }
        }
        if(trigger.isUpdate){
           for(User u : trigger.new){
             if(u.ProfileId == '00e16000001GkRp' || u.ProfileId == '00e16000001GkRk' || u.ProfileId == '00e16000001GkS4'){
                     publicGroup.GroupId = '00GA0000000U7Cs';
                    publicGroup.UserOrGroupId = u.Id;
                    Database.insert(publicGroup);
               }else if(u.ProfileId == '00e16000001GkRf' || u.ProfileId == '00e16000001GkKU' || u.ProfileId == '00e16000001GkRz'){
                   publicGroup.GroupId = '00G16000005ReMc';
                   publicGroup.UserOrGroupId = u.Id;
                   Database.insert(publicGroup);
               }
           }
        }
    }
}


Hete is teh test code

@isTest
public class Teste_User_Public_Group {
    
    @isTest
    public static void criarUsuarioArquiteto(){
       User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        User user;
        Account a;
        
        Group gp = new Group(Name = 'Teste');
        insert gp;
        
        a = [SELECT Id, Name FROM Account WHERE Name = 'Comunidade Service IT - Comercial'];
        
        Contact con = new Contact (FirstName='Teste1', LastName='Teste2', AccountId = a.Id);
        insert con;
        
        System.runAs (thisUser){
        user = new User(ContactID = con.Id,  FirstName = 'Test', LastName='User2', ProfileId = '00e16000001GkKU', Username = 'Teste@teste.com', Email= 'Teste@teste.com', Alias ='teste', EmailEncodingKey='UTF-8', LocaleSidKey='en_US', LanguageLocaleKey='en_US', TimeZoneSidKey='America/Los_Angeles', UserRoleId='00E1600000156aP');
        insert user;
        
        GroupMember gpm = new GroupMember();
        gpm.GroupId = gp.Id;
        gpm.UserOrGroupId = user.Id;
        Database.insert(gpm);
        } 
    }
    @isTest
    public static void criarUsuarioVendedor(){      
        
        Group gp = new Group(Name = 'Teste');
        insert gp;
        
        Account a = new Account(Name = 'Test Account', Regional__c = 'SP');
        insert a;
        
        Contact con = new Contact (FirstName='Teste1', LastName='Teste2', AccountId = a.Id);
        insert con;

        User user = new User(ContactID = con.Id, FirstName = 'Test', LastName='User2', ProfileId = '00e16000001GkKU', Username = 'Teste@teste.com', Email= 'Teste@teste.com', Alias ='teste', EmailEncodingKey='UTF-8', LocaleSidKey='en_US', LanguageLocaleKey='en_US', TimeZoneSidKey='America/Los_Angeles', UserRoleId='00E1600000156aP');
        insert user;
        
        GroupMember gpm = new GroupMember();
        gpm.GroupId = gp.Id;
        gpm.UserOrGroupId = user.Id;
        Database.insert(gpm);
        
    }
    
    @isTest
    public static void atualizarUsuario(){
        Group gp = new Group(Name = 'Teste');
        insert gp;
        
        Account a = new Account(Name = 'Test Account', Regional__c = 'SP');
        insert a;
        
        Contact con = new Contact (FirstName='Teste1', LastName='Teste2', AccountId = a.Id);
        insert con;

        User user = new User(ContactID = con.Id, FirstName = 'Test', LastName='User2', ProfileId = '00e16000001GkKU', Username = 'Teste@teste.com', Email= 'Teste@teste.com', Alias ='teste', EmailEncodingKey='UTF-8', LocaleSidKey='en_US', LanguageLocaleKey='en_US', TimeZoneSidKey='America/Los_Angeles', UserRoleId='00E1600000156aP');
        insert user;
        
        User u = [SELECT Id, ProfileId FROM User Where Id = : user.Id];
        u.ProfileId='00e16000001GkKU';
        update u;
    }
}

here is the message error that show.
System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION,
System.QueryException: List has no rows for assignment to SObject
System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION,

Can someone help me?

Thanks

Rafael
Hi,

I create a visualforce page.
When some event is executed the follow message are showing in the page:
window.parent.SfdcApp.Visualforce.viewstate.ViewInstance.reload

how I remove this from the page?

Thanks.

Rafael
Hi All,

I want know how display an error message on the visualforce page?

Thanks
Rafael
Hi All,
I'm trying optimize my code, so I need help.
Let me explain first how works my code.

I have a table in my page that brings a list of accounts with your fields.
Each of these fields is a field of type Choice List, and when I select an option the account are updated.
Here is the image of my table:
User-added image

The only way I could update the field is creating for each column a function in Javascript and a Method in APEX.
Javascrit:
function gravar(id, status){
     var id_conta = id;
     var nome = document.getElementById(status).value;
     executar(id_conta, nome);
    }

Apex:
        public pageReference Save(){
            System.debug('Executou ');
            id_conta = System.currentPageReference().getParameters().get('id_contas');
            status_conta = System.currentPageReference().getParameters().get('suporte_status');
            
            for(Account conta : [SELECT Id, Name, ServiceNow_Status__c, Suporte_Status__c, Adm_Status__c, BS_BH_Status__c FROM Account                                             WHERE Id =: id_conta]){
                conta.Suporte_Status__c = status_conta;
                update conta;
            }

           return null;
        }

The problems is, if I have 45 columns I must create 45 funcions and Apex Methods.
I want create only 1 Function and only 1 Method that Allow to me update the field.
The process will update each field at a time.

Can someone help me to optimize my code?

Thanks
Rafael.
 
Hi All,

How do I update a table ("<table>") without refresh the page?

for example:

I have a <td> and inside of this tag I have a Select options field, that when I change the value, fire a actions that update the value in account and deppending of the value the cell of this <td> must update with a background color.
The value update on the account normally but the color of the cell is changing after I reload the page.
But the problem is, if I reload the page, I lost all the data that are displaing in the page, forcing me to make a search again.

So, I want update the account, update the background cell and remain with the all current data.

is it possible?

Thanks

Rafael 
Hi,
I have a code that verify if have at least 1 attachment in a opportunity.
The code was working normally but when I change to Lighting expecience mode, the SOQL of the Attahment don't work no more.
Do you know what is the problem? and How I can fix this if there is a way.

Here is my code:

Trigger Valida_Anexo on Opportunity (before insert, before update) {
    
    if(trigger.isInsert){
        for (Opportunity op : trigger.new) {
            if(op.StageName == 'Proposta Comercial' || op.StageName == 'Aposta'){
               op.addError(' Você precisa anexar o documento \"Proposta Comercial\" para seguir para etapa \"' +op.StageName + '\"');
            }

            if(op.StageName == 'Fechado e ganho'){
               op.addError(' Você precisa anexar o documento \"Proposta Comercial\" para fechar esta esta oportunidade');
            }
        } 
    }
    
    if(trigger.isUpdate){
        for (Opportunity op : trigger.new) {
        Integer c = 0;
        System.debug('Foi atualizado, contador: '+c);
            // THE LIST RETURN EMPTY
            LIST<Attachment> attachments = [SELECT Id, Name, ParentId FROM Attachment WHERE ParentId = : op.Id];
            System.debug('Lista de anexos: '+attachments);
          //THE CODE DON'T EXECUTE THIS FOR
          for(Attachment att : attachments){
              System.debug('Nome: '+ att.Name+', Contagem de anexos: ' + c);
              c++;
          }
            if(op.StageName == 'Proposta Comercial' && c == 0 || op.StageName == 'Aposta' && c == 0){
                System.debug('Estrou primeiro if, contador: '+c);
               op.addError(' Você precisa anexar o documento \"Proposta Comercial\" para seguir para etapa \"' +op.StageName + '\"');
            }

            if(op.StageName == 'Fechado e ganho' && c < 1){
                System.debug('Estrou segundo if, contador: '+c);
               op.addError(' Você precisa anexar o documento \"Proposta Comercial\" para fechar esta esta oportunidade');
            }
           }
    }
}

Best Regards
Rafael
Hi All,

I'm trying understand how the handler works but I don't understand yet.

I want know what is handler and how does he works?

is there exist some document that explain how is it work step by step?

Thanks
Rafael.
Hi,

I want know if is possible separate the css, javascript in differents files and call then in HTML visualforce page? is it possible?

Best Regards
Rafael.
Hi,
I have a table that will display a list of accounts and a field of type "Choice List".
until now this working, but I must enable for the user select another options of the choice list and save.
I can't add an Id on the tag "inputfield" because the the tags are generated automatically by the tag apex:repeat.
is there some another way to do that?

Best Regards
Rafael
Hi

I have a table that will have a status value. According of the value, the color of the background cell will change.
I want know how can I do that?
For example:

<tr>
<td>Value 1</td>
<td>Value 2</td>
</tr>

Value 1 must be the color blue
Value 2 must be the color red 

Best Regards
Rafael
Hi,

I want know if is possible to create a tag using apex code.

for example

List<String> accounts

accounts.add(<tr><td>account.Field</td></tr>)

When the code is executed in the visualforce will appear
<table>
//TR and TD created by apex
<tr>
<td>Account Value</td>
</tr>
</table>

is it possible to do?

Best Regards
Rafael
Hi,

I need fill some columns with data, until now I can fill the first collumn, but I need fill the others 3.
The problem that I'm facing is that I have to use the SAME Object e get the value of the same field, but with a different filter.

for example:

Opprtunity op1 = [SELECT Id, StageName FROM Opportunity WHERE StageName = 'Closed'];
Opprtunity op2 = [SELECT Id, StageName FROM Opportunity WHERE StageName = 'Open'];

So, I need display in a column the stage of op1 and in another column I must display the stage of op2.

The Ideia is create 1 method for each QUERY, so I can display each one side by side in the same row.

Can someone help me?
Any other suggest please.

Best Regards
Rafael
 
Hi,

I need fill some columns with the value of the same field, but until now I can't make this work. So I wondering if I can use a variable of type list to get all the informations that I need and display in a table that each value will be separated by <tr><td>VALUE[0]</td></tr>
is it possible?

Best Regards
Rafael
Hi,
I'm trying to populate a table with some especifics values.
So I will explain what I want to do.
User-added image
  • In the first column I have the a list of accounts
  • in the second column ("Suporte") I must display only the Status of a Product that have a relationship with Account.
  • In the Third column ("Adm") I must display only the Status of a Product that have a relationship with Account.
  • In the fourth column ("BS/BH") I must display only the Status of a Product that have a relationship with Account.
  • In the fourth column ("ServiceNow") I must display only the Status of a Product that have a relationship with Account.
In my actual code I can only display one register if I filter by especifi Product(For example : Suporte) .

Object Account
Object Produto_da_Mancha__c
  • Each Account have a number of products
  • Each product have a Status.
So, I must display Something Like this:
  • Account Name - Status (Product Suporte) - Status (Product Adm) - Status (Product BS/BH) - Status (Product ServiceNow)

Below I share my visualforce code and APEX Code.

Apex Code:

public class Account_Mancha {
    
      public Account_Mancha(){
          
      }
    
    public List<Account> getTodasContas(){
        
        List<Account> accounts = [SELECT Account.Id, Account.Name, (SELECT Produto_da_Mancha__c.Name, Produto_da_Mancha__c.Conta_Id__c, Produto_da_Mancha__c.Status__c FROM Produtos_da_Mancha__r WHERE Produto_da_Mancha__c.Conta_Id__c != null AND Produto_da_Mancha__c.Name = 'Suporte') FROM Account];
        
       return accounts; 
    }
}

Visualforce Code:
<apex:page showHeader="false" sidebar="false" standardStylesheets="false"
applyHtmlTag="false" applyBodyTag="false" docType="html-5.0" controller="Account_Mancha">
<html>
<head>
    <title>Mancha</title>
    <style>
        CSS Style HERE...

    </style>
</head>
<body>
    <header>
        <div class="bar_container">
            <ul>
            <li>
                <a href="">Oportunidade</a>
            </li>
            <li>
                <a href="">Contas</a>
            </li>
            <li>
                <a href="">Contatos</a>
            </li>
        </ul>
        </div>
    </header>
    <div class="painel">
        <h1>MANCHA</h1>
        <table>
            <tr>
                <th colspan="1" class="celula_em_branco"></th>
                <th colspan="4" class="celula_azul_escuro">MANAGED SERVICES</th>
            </tr>
            <tr>
                <td class="cor_cinza">Conta</td>
                <td class="cor_cinza">Suporte</td>
                <td class="cor_cinza">Adm</td>
                <td class="cor_cinza">BS/BH</td>
                <td class="cor_cinza">ServiceNow</td>
            </tr>
           <apex:repeat value="{!TodasContas}" var="conta">
           <tr>
            <td class="celula_azul_escuro">{!conta.Name}</td>
            <apex:repeat value="{!conta.Produtos_da_Mancha__r}" var="produtos">
            <td class="cor_azul">{!produtos.Status__c}</td>
            <td class="cor_verde">HERE MUST BE ADM STATUS</td>
            <td class="cor_amarelo">HERE MUST BS/BH STATUS</td>
            <td class="cor_azul">HERE MUST BE SERVICENOW STATUS</td>
            </apex:repeat>
            </tr>
          </apex:repeat>
        </table>
    </div>
    <footer>
        <div class="bar_container">
            <ul>
                <li>Company Name</li>
            </ul>
        </div>
    </footer>
</body>
</html>
</apex:page>

I really need a help on this.

Thanks

Rafael
Hi,

I'm trying to get a child field with SOQL, but I not have success.

I must get the fields of Object Account and Object Product_Account (Child of Account).

I write A query like this:

LIST<Account> accounts = [SELECT Account.Name, (SELECT Product_Account__c.Status__c FROM Product_Account __r) FROM Account];
for(Account account : accounts){
 System.debug('Account Name: ' + account.Name + ', Product Name: '+ HERE I WANT GET THE VALUE FROM "Product_Account__c.Status__c" FIELD);
}

Is it possible to do?

Thanks
Rafael

 
Hi All,

I need create a validation to check if exist attachments in the opportunity.
Someone know if is possible to do that?

I need create something like that:
If Probability is =  75% , verify if exist at least 1 file attached in the opportunity, before the user proceed to the next stage.

Thanks
Rafael
 
Hi,

I want change the format of the currency for the BRL Currency.
So for example, I want change this format "1,000.00" to this format "1.000,00"
Note: The comma to BRL is the decimal separator.

Someone knows how change that?

Best Regards
Rafael
 
Hi All,

I'm trying understand how the handler works but I don't understand yet.

I want know what is handler and how does he works?

is there exist some document that explain how is it work step by step?

Thanks
Rafael.
Hi,

I want change the format of the currency for the BRL Currency.
So for example, I want change this format "1,000.00" to this format "1.000,00"
Note: The comma to BRL is the decimal separator.

Someone knows how change that?

Best Regards
Rafael
 
Hi,

I have a custom object child of the opportunity object.
I want make a SOQL from the child to get the data of the Opportunity.
Someone know how I do that?
Some best practice in this case.

Thanks

Rafael
Hi
I have a child object classed OpportunityItem__c that the parent is Opportunity, and in the OpportunityItem__ I have a relationship field that get the Id from an Object called Goal__c.

In the OpportunityItem__c I have a trigger, in these trigger I have to get the Opportunity Id and get the Goal Id too.

My code is like this:

for(OpportunityItem__c item : trigger.new)
{
opportunityId = item.OpportunityId; //(relationship field Name in OpportunityItem__c)
year = item.CloseDate__c;
}
  list<Goal__c> goalsList = [SELECT Id, Year__c FROM Goal__c WHERE Year__c =: year];
  list<Opportunity> opportunities = [SELECT Id, Name FROM Opportunity WHERE Id=: opportunityId ];

Until here ok.
But When I test, both list get a exception of SOQL Limit 101.
I want some manner to get the data of Goal and Opportunity that have relationship with the current item that fire a trigger.

Someone knows how I do that?

Best Regards
Rafael
Hi,

I create a visualforce page.
When some event is executed the follow message are showing in the page:
window.parent.SfdcApp.Visualforce.viewstate.ViewInstance.reload

how I remove this from the page?

Thanks.

Rafael
Hi All,

I want know how display an error message on the visualforce page?

Thanks
Rafael
Hi All,
I'm trying optimize my code, so I need help.
Let me explain first how works my code.

I have a table in my page that brings a list of accounts with your fields.
Each of these fields is a field of type Choice List, and when I select an option the account are updated.
Here is the image of my table:
User-added image

The only way I could update the field is creating for each column a function in Javascript and a Method in APEX.
Javascrit:
function gravar(id, status){
     var id_conta = id;
     var nome = document.getElementById(status).value;
     executar(id_conta, nome);
    }

Apex:
        public pageReference Save(){
            System.debug('Executou ');
            id_conta = System.currentPageReference().getParameters().get('id_contas');
            status_conta = System.currentPageReference().getParameters().get('suporte_status');
            
            for(Account conta : [SELECT Id, Name, ServiceNow_Status__c, Suporte_Status__c, Adm_Status__c, BS_BH_Status__c FROM Account                                             WHERE Id =: id_conta]){
                conta.Suporte_Status__c = status_conta;
                update conta;
            }

           return null;
        }

The problems is, if I have 45 columns I must create 45 funcions and Apex Methods.
I want create only 1 Function and only 1 Method that Allow to me update the field.
The process will update each field at a time.

Can someone help me to optimize my code?

Thanks
Rafael.
 
Salesforce.com could not email the report to any of the specified recipients. Check that recipients are specified and that they have the appropriate permissions to view the report.

If you get this ^error:

Make sure you also check:
Setup > Customize > Reports & Dashboards > Email Notifications > Allow Reports and Dashboards to Be Sent to Portal Users

Posting this here since it took me a long time to find this checkbox.