• Dixit
  • NEWBIE
  • 125 Points
  • Member since 2015

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 85
    Replies
I am trying to set up a connection where I can connect two custom objects that have the same custom field values such as first, last name, and/or zipcode, via a look up field that connects them by their salesforce generated record ID. If matching records based off of these custom feilds are found then the connection needs to autopopulate this lookup field that points back to each objecet, which in this case is just the standard Salesforce generated ID of each record in their respective custom object.

I was able to get started with some help and have come up with the apex trigger code below, that i wrote to match just based off of one custom field match in First Name, once I get the basic structure down then I will expand to include other custom fields too match. 

However, I am running into an error on line 13 where it says Incompatible key type Schema.SObjectField for Map<String,Voter_File__c>.  Also for the purpose of just figuring out this inital code and logic i've simplfied it to only look for matches base off first name.

With this my first custom objects= TGA Email List, and my second is= Voter File

Where the lookup field I am trying to update is Voter_ID_del__c on the TGA Email List custom object, where Voter_ID_del__c is the salesforce generated id record for a record in the Voter File custom object. 

Also note because realtionships between these two custom objects should be one to one, there is a lookup field on the Voter File object that reads Email_ID_del__c which is simply the Unique salesforce generated id record of the TGA Emai List Record. 

Am I on the right track so far also is there anything wrong I am doing. Thanks. 
 
trigger EmailtoVoterFile on TGA_Email_List__c (before insert,before update,after insert,after update)
{
	Set<String> set_Str = new Set<string>();
    Map<String,Voter_File__c> mp_voterfileObj;
    
    if(Trigger.isAfter && Trigger.isUpdate)
    {
        for(Voter_File__c voterfileobj : [Select ID,First_Name__c,Email_ID_del__c From Voter_File__c])
        {
            		if(mp_VoterfileObj==null)
                        mp_VoterFileObj = new map<String,Voter_File__c>();
        
            mp_VoterFileObj.put(Voter_File__c.First_Name__c,VoterFileObj);

 
                    }
        
        for(TGA_Email_List__c TGAEmailListobj : Trigger.new)
    {
        if(mp_VoterFileObj!=null && mp_Voter_File__c.containsKey(TGA_Email_List__c.First_Name__c))

        {

       mp_Voter_File__c.get(TGA_Email_List__c.First_Name__c).Voter_ID_del__c = Voter_File__c.id;

}

}
 
if(mp_VoterFileObj!=null && mp_Voter_File__c.values()!=null)
		update mp_Voter_File__c.values();

    }
}


 
I got the error saying: The 'Cases by Status' report is not grouped by Case status
but the CASES type does not have a column called "Status"
the standard report type can't be modified, so how can I make it work and pass the test?

below is my screenshot, i have 'open' and 'closed' in 2 columns, but no 'status'

thanks a lot to anyone who can help! 
User-added imagef
  • February 09, 2017
  • Like
  • 0
In the Spring 2017 release, "Sales Paths" are renamed "Paths", so I guess this is why the challenge does not pass with the following message:
Challenge Not yet complete... here's what's wrong: 
The sales path should not be published.

I did activate the path as required in the challenge.

Please can you confirm and update the challenge, or else tell me where I am wrong?
Hello, I'm doing this challenge in trailead which says I need to create a profile and give some access with permission sets... ok
(you can see all the challenge here: https://trailhead.salesforce.com/es-MX/trails/force_com_dev_beginner/modules/data_security/units/data_security_fields

Well I already did my profile and set the permissions on the object and field as follows: 
User-added image

And of course, removed the read/edit access to the "rating" filed. 

User-added image

Also did the permission set, but my problem is when I click the "Check challenge" button it shows an error saying:

Challenge Not yet complete... here's what's wrong: 
The 'Account' profile did not have the appropriate object and field-level security for the Account object.


I don't know what else to do... honestly. 
I already tried quiting the "create" permission on the object... giving the "read all" permission... re-make the profile 3 times... check the boxes for "show" and "read only" in the field security level > check the challenge > uncheck the boxes > check the challenge.... 

I don't know what is happening.
  • July 14, 2017
  • Like
  • 0
Hello, 

I have this commandlink on a visualforce page:
 
<apex:commandlink action="{!saveProdChanges}" rerender="Messages" value="Save" immediate="true" styleclass="buttonprod" onclick="console.log('click save')">
                                                                    <apex:param name="buttonsave" value="{!product.id}" id="saveParam" assignTo="{!saveProd}"/>                                                                  
                                            </apex:commandlink>

which calls this method on my controller:
public string saveProd {get; set;}

public pageReference saveProdChanges(){

producto_simulacion__c productoEdit = new producto_simulacion__c();
productoEdit = [SELECT Id, categoria__c, cantidad__c, importe__c, descripcion__c, costo_unitario__c FROM producto_simulacion__c WHERE id =: saveProd];

update productoEdit;
}
I edited so i can try the button, I also trying with just:
 
public pageReference saveProdChanges(){

system.debug('Hello, this is saveProdChanges method');

}

but is not doing anything when i press the button. Browser console is not showing any error, it's displaying correctly the console.log on it.
Log in developer console is not showing the debug, but it does a log when I click it....

What could be wrong?

 
  • April 06, 2017
  • Like
  • 0
Hello, 

I did a chart in a visualforce, my chart has only 2 values to draw as bars in bar chart, but i notice that the draw of the bar doesn't match with the value on the Y-Axis, for example this case: 

bar Graphics

My first bar has a value of: $43'595'258.62 but if you go to the Y-Axis and look where the graphic is ending it is in the 45'000'000 final value.

Why is it acting like that?

This is my chart (VF) :
 
<apex:chart data="{!data}" height="300" width="400" resizable="True">
    <apex:axis type="Numeric" position="left" title="Total MXN" fields="data1" maximum="{!maximum}" minimum="0" />
    <apex:axis type="Category" position="bottom" fields="name" />        
    <apex:barSeries orientation="vertical" axis="left"
        xField="name" yField="data1" title="Simulacion"/>
</apex:chart>

This is my controller:
public Data[] getData() {
     
        if(simulacion.importe__c >= simulacion.plantilla_relacionada__r.importe_total__c){
            maximum = simulacion.importe__c;
        } else {
            maximum = simulacion.plantilla_relacionada__r.importe_total__c;
        }
/* I don't know if i need to have this maximum and min values in my chart, but when i declare it it turns a more specific graphic bar than when i don't do this. I can only have 2 and only 2 values in my chart, that's why i need to choose between those, which one is the bigger. */  

    return new Data[] {
        new Data('test1', simulacion.Importe__c),
        new Data('test2', simulacion.plantilla_relacionada__r.Importe_Total__c)
        };
        
    }



 
  • December 22, 2016
  • Like
  • 0
Hello, 

I just created a Lightning component with the 'implements="force:appHostable"' attribute in the aura:component tag. 
I have changed My Domain already. 

But when I go to lightning tabs, when selecting the lightning component always shows "-none-" and nothing else... 

Am I missing something?
 
  • November 07, 2016
  • Like
  • 0
Hello!~

I'm having trouble to find the best option to do a summary record with n records of the same type. 
Let me explain. 

I have a VF with a extension which gives me a list of a custom Object (ex: List<products__c> prods) i have this "products" n times with differents IDs but some with the same model...
So i have a WrapperClass that recives as a parameter a list of products. (Public productWrapper (List<products__c> p))
I want to summarize the quantity of products of the same model.

EX (i get in the list) 
ID     MODEL  QUANTITY  
01       A           10
02       B            5
03       C            1
04       A            3
05       A            5
06       B            10
07       C            20

so i want my wrapper class to tell me:
Model A: 18 pieces
Model B: 15 pieces
Model C: 21 pieces


but i don't know how exactly to achieve that... 
I know that an AggregateResult list should work but i will group those models for differents parameters and sumarize it as well for those parameters....

Any help?
Thanks.
  • February 18, 2016
  • Like
  • 0
I have a Trigger on Opportunity which is working fine except for 1 field.... 
 
for(Opportunity run: Trigger.new){

 Opportunity old = Trigger.oldMap.get(run.Id);
        if (trigger.isupdate && run.invitar_al_centro_de_experiencia__c == true && old.invitar_al_centro_de_experiencia__c == true )
        {

 invitacion_al_centro_de_experiencia__c cand = new invitacion_al_centro_de_experiencia__c();
                cand = [SELECT id, name FROM invitacion_al_centro_de_experiencia__c WHERE oportunidad_relacionada__c =: run.id LIMIT 1];

 cand.Tipo_de_Oportunidad__c = string.valueof(run.recordtype.name);

}

}

The "run.recordtype.name" returns null
but if i change that line to "run.recordtypeid" it shows me the recordtype ID indeed. 
I tried with and without the "string.valueof()" and still getting "null"...and checked out the recordtype and it does have a name....
(I cut the code, so sorry if there is not a "{", "}", or anything written) 

What am i doing wrong?
  • January 26, 2016
  • Like
  • 0
Hello, I will appreciate your help on this please: 
Need help to understand what I am doing wrong.

In developer intermediate section of trailhead
API Basics: Use bulk API challenge

Import Accounts Using Bulk API and Workbench
Using Bulk API and Workbench, import these account records (a CSV file).

This is what I tried in workbench:

Step 1:  /services/data/XX.0/jobs/ingest
Executed POST

Step 2: /services/data/XX.0/jobs/ingest/jobID/batches
Changed Headers Content-Type to text/csv
"/Users/ediz/Downloads/bulkv2hocdata.csv"
Executed PUT

Step3: /services/data/XX.0/jobs/ingest/jobID. 
In the request body, replaced the text with the following JSON text.
{
   "state" : "UploadComplete"
}

Executed PATCH
 
Hello, I'm doing this challenge in trailead which says I need to create a profile and give some access with permission sets... ok
(you can see all the challenge here: https://trailhead.salesforce.com/es-MX/trails/force_com_dev_beginner/modules/data_security/units/data_security_fields

Well I already did my profile and set the permissions on the object and field as follows: 
User-added image

And of course, removed the read/edit access to the "rating" filed. 

User-added image

Also did the permission set, but my problem is when I click the "Check challenge" button it shows an error saying:

Challenge Not yet complete... here's what's wrong: 
The 'Account' profile did not have the appropriate object and field-level security for the Account object.


I don't know what else to do... honestly. 
I already tried quiting the "create" permission on the object... giving the "read all" permission... re-make the profile 3 times... check the boxes for "show" and "read only" in the field security level > check the challenge > uncheck the boxes > check the challenge.... 

I don't know what is happening.
  • July 14, 2017
  • Like
  • 0
Hello, 

I have this commandlink on a visualforce page:
 
<apex:commandlink action="{!saveProdChanges}" rerender="Messages" value="Save" immediate="true" styleclass="buttonprod" onclick="console.log('click save')">
                                                                    <apex:param name="buttonsave" value="{!product.id}" id="saveParam" assignTo="{!saveProd}"/>                                                                  
                                            </apex:commandlink>

which calls this method on my controller:
public string saveProd {get; set;}

public pageReference saveProdChanges(){

producto_simulacion__c productoEdit = new producto_simulacion__c();
productoEdit = [SELECT Id, categoria__c, cantidad__c, importe__c, descripcion__c, costo_unitario__c FROM producto_simulacion__c WHERE id =: saveProd];

update productoEdit;
}
I edited so i can try the button, I also trying with just:
 
public pageReference saveProdChanges(){

system.debug('Hello, this is saveProdChanges method');

}

but is not doing anything when i press the button. Browser console is not showing any error, it's displaying correctly the console.log on it.
Log in developer console is not showing the debug, but it does a log when I click it....

What could be wrong?

 
  • April 06, 2017
  • Like
  • 0
Hello Developers,

I have the trigger below that counts the number of Opportunities that are assigned to the Account and displays them on the Contact redord. I need this trigger to only count the Opportunities that the Contact is assigned to via the Opportunity Contact Role and the field in the Opportunity called STS Currently Engaged is TRUE. Any assistance will be greatly appreciated!!
trigger RollUpSTSOpportunity on Opportunity (after delete, after insert, after update) 
{
    set<Id> setAccountIds = new set<Id>();
    map<Id, Integer> mapAccountToOpp = new map<Id, Integer>();
    List<Contact> lstContactUpdate = new List<Contact>();
    
    if(trigger.isInsert || trigger.isUpdate)
    {
        for(Opportunity o : trigger.new)
        {
            setAccountIds.add(o.AccountId); // take all the related Account Id's in a set from trigger.new in case of insert/update
        }
    }
    else
    {
        for(Opportunity o : trigger.old)
        {
            setAccountIds.add(o.AccountId); // take all the related Account Id's in a set from trigger.old in case of delete
        }
    }
    
    for(Account a : [Select Id, (Select Id From Opportunities) From Account Where Id In :setAccountIds])
    {
        mapAccountToOpp.put(a.Id, a.Opportunities.size()); // add each account id with the number of opportunities related to it
    }
    
    for(Contact c : [Select Id, AccountId, Related_STS_Opportunities__c  From Contact Where AccountId In :mapAccountToOpp.keySet()])
    {
        c.Related_STS_Opportunities__c  = mapAccountToOpp.get(c.AccountId);  // from the contact, we can get the number of opp related to it's parent account
        lstContactUpdate.add(c);
    }
    
    if(lstContactUpdate.size() > 0)
        update lstContactUpdate; // update the contacts
}

 
  • February 13, 2017
  • Like
  • 0
Hello all,

I am new to Apex Code and I am trying to build a trigger to the following task.
Each time we insert new Opportunities throug a bulk insert, we have Opportunites in the system that are listed as scheduled, that are equal or same as Opportunities Won. So I want my trigger to delete the scheduled Opportunity that is equal to the Won Opportunity.

When the Opportunity is inserted it will check three fields that need to all match for Opportunity scheduled to be deleted.
StageName = "Peformed" Which is always the case when inserting new bulk Opportunites 
Contact_ID = "Contact_ID"  Which is the first field it should look for to find a duplicate Opportunity.
ClosedDate = "Date" Which is the date we enter for the Opportunity that will match the scheduled Opportunity
 
Example Giving: New Opportunity Inserted: 
StageName = Performed 
ContactID = John Doe
ClosedDate = 2/13/2017

Found Scheduled Opportunity to be deleted:
Stage Name = Scheduled
ContactID = John Doe
ClosedDate = 2/13/2017

Here is what i have so far: 

trigger myTrigger on Opportunity (before insert) {

    for (Opportunity opp : Trigger.new){
    
        if (opp.StageName = 'Performed'){
        
        Opportunity Opp = new Opportunity();
        
        Opp.StageName      = 'Surgery Performed';
        Opp.ContactID         = 'Check for same ContactID;
        Opp.ClosedDate      =  'Check for same ClosedDate;
       
        delete opp;
        }
    }
}

Sorry for my ignorance and lack of knowledge in this topic, i know this may seem very silly to ask, but I am desperate to know if this can be done by a trigger and not to be manually searched to find a duplicate to delete.

Thank you in advance.

I have two custom objects, a parent and a child.  I have a requirement to be able to clone the child object record.  

  • The Clone button is avialable when I edit the page layout, but is not visible on the live layout.
  • I have searched for a permission I may have missed but am having no luck.  
  • The child object records are not governed by record types.
  • I do not need a custom clone button, I simply want to clone the record and edit where required.
Looking forward to your response.

 

I'm having a difficult time finding the answer to this question.

I coded up a before insert trigger that checks both the insertion set (all leads being currently inserted) as well as existing Leads+Contacts to see if the leads trying to be inserted already exist or are duplicated in the insertion set. The check is a cross-check on their email or alt-email for the insertion set itself, Leads, and Contacts.

I prevent the insertion of duplicate leads by adding an error when a duplicate is found (either in the insertion set, or already existing Lead/Contact in Salesforce), but doing this unfortunately rolls back the insert preventing that lead from being inserted and trying to insert again without that lead (as Salesforce does). This does not work for our purposes because ultimately if 2 leads insert at the same time (in the same insertion set) from our web insert they should merge into 1, not simply stop the second insert.

Instead of removing the duplicated lead from being inserted entirely, in cases where the existing Lead/Contact can be updated, or 2 leads are being inserted in this insertion set that are duplicated and can be merged I would like to update / merge the Leads, but I can't do that if it rolls back the insertion of all leads when I error the insert of 1 lead.

In short:

How can I prevent insertion of a single Lead in my insertion set without it rolling back and restarting the trigger (removing the lead from the insertion set and running the insert again) so that in the trigger itself I can either A: merge the lead with the other lead in the insertion set which is a duplicate, or B: update the existing Lead / contact with the new information.

Right now I'm thinking that this isn't possible and instead I should allow the lead to insert but set some sort of flag on it that says "Duplicate of LEAD_ID / CONTACT_ID" and then run a trigger after insert that merges the duplicated lead with the existing/duplicated-in-set lead/contact. Would that work? Is there a cleaner way of doing this? What am I not thinking about / should I keep in mind with this insertion logic?

Any assistance here is much appreciated. Thanks!
I'm trying to setup a fairly? simple process? (I am stumped as to what I'm supposed to be using) on a lead, that using a trigger like a LeadStatus change will automatically send off an email template to that lead, and will create a task (phone call). Once that task has been completed, a second email will be automatically sent after a certain amount of time, followed by a second phone call task, rinse and repeat through one more cycle. 

I'm at a bit of a loss as to exactly what I'm supposed to be using. I've tried process and workflow and can get part of it done but can't seem to setup the whole process. Consider me a lost newbie. Any help learning how to fish would be great.
I wanted to figure out if there is or if there is any plan to open challenges data via an api so that we can reward employees for completing trialhead data.
I am having the following problem while trying to deploy a custom object through the eclipse force.com tool.


Any ideas?

Deploy Results:
   Name:    unpackaged/objects/Business_Trip_Meeting__c.object
   Action:  NO ACTION
   Result:  FAILED
   Problem: Cannot specify a gender for a gender neutral language