+ Start a Discussion
Daan LuttikDaan Luttik 
Our goal is to merge Contacts (and later Accounts) in Salesforce CRM. Our data is already polluted therefore we can't rely on merge rules that are triggered only for new/changed contacts.

Therefore we think that we need to utilize Apex code however we are running into some issues that seem to have to do not with the code but with the permissions:
(Important to note about the code below, the emails in the contacts are fake and can therefore be ignored completely when merging).
public class MergeRule {
    public static void applyMergeRule() {
        AggregateResult[] contacts = [
            SELECT Name, BirthDate, COUNT(Email) nr
            FROM Contact GROUP BY Name, BirthDate
            HAVING COUNT(Email)>1
        ];
        for (AggregateResult contact_group: contacts) {
            String name = (String)contact_group.get('Name');
            Date birth_date = (Date)contact_group.get('BirthDate');
            Contact[] contact_subgroup = [
                SELECT Id, Name, BirthDate
                FROM Contact
                   WHERE Contact.Name = :name
                   AND Contact.BirthDate = :birth_date
						];
            for (Integer i=1; i<contact_subgroup.size(); i++){
								// This line produces the error 👇 🔔
                merge contact_subgroup[0] contact_subgroup[i];
            }
        }
    }
}

We receive the following error:
14:07:03:138 FATAL_ERROR System.DmlException: Merge failed. First exception on row 0 with id 0035r000002VYMoAAO; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.: [Name]
We have tried to change the field level security for the profile System Admin on the field Name for the Contacts object, however, we found that there is no way to change this field. We tried this due to the suggestions in this thread on the salesforce development forum (https://developer.salesforce.com/forums/?id=9060G0000005PvhQAE) and this thread on the salesforce stackexchange (https://salesforce.stackexchange.com/questions/69857/how-to-check-whether-a-user-has-write-access-to-a-field), however, we are not completely sure that we interpreted these threads correctly (maybe we need to change the permissions for other profiles, objects or fields instead of the ones above?)

I hope that you can help us with this issue.
Best Answer chosen by Daan Luttik
Daan LuttikDaan Luttik
For us, the issue, in the end, was that we retreived the contact not only with the Id but also with the Name and BirthDate.
When we changed the contact_subgroup query to the following it all worked:
Contact[] contact_subgroup = [
SELECT Id,
FROM Contact
WHERE Contact.Name = :name
   AND Contact.BirthDate = :birth_date
];
Laura KempenaarLaura Kempenaar 
Hi all,

Another question from me: I am still working on the admin module within Trailheads and I cant finish it, because in the Create object specific quick actions-part I can't seem to find Properties under Tabs. I did create Property/Properties as an object, but then I have to do this:

Enter Tab in the Quick Find box, then select Tabs.
In the Custom Object Tabs list, click New.
In the Object dropdown list, select Property.

And in that object dropdown list, there is no Property. Can someone tell me what to do here, please? Thanks! :)
Best Answer chosen by Laura Kempenaar
Andras Arva(HU)Andras Arva(HU)
hey @Laura Kempenaar
I was in the same situation, reviewed tab access, even FLS but did NOT helped.
After a while i noticed that if i scroll UP in my mobile it refresh my tabs list ! (where you generally see tabs/recent/connections etc.)
And this was necessary as probably tab names were cached (if i use another mobile to connect that could work w/o it)
Sowjanya Hegde 13Sowjanya Hegde 13 
I have created Lead and I have set the Lead owner as Queue. Then I converted Lead to Opportunity. Now If I check the Lead owner it shows logged in user(myself) as a Lead owner. How can I fecth the actual lead owner(QUEUE) after lead conversion ? Please help!
Best Answer chosen by Sowjanya Hegde 13
Sowjanya Hegde 13Sowjanya Hegde 13

I was able to fetch the ownerId after the conversion of the Lead with the following code:

if (Trigger.isBefore) {
   if (Trigger.isUpdate) {
   for (Lead ld : Trigger.new) {
      Lead leadDetail = trigger.oldmap.get(ld.Id);
      Id ownerIdBeforeConvert = leadDetail.OwnerId;
   }
 }
}

Roman RauerRoman Rauer 
Hi there :)

i'm currently working on an native Android app for my company and ran into some problems with Salesforce lately.

I hope i can find some help here.

What i want to achieve:
The company has a lot of Accounts in Salesforce with 3 important fields for the app: Name, Business (Workshop or Parts Dealer) and location(latitude, longitude)
I would like to show those Accounts(Workshops/Parts Dealers) as markers on a google map in my Android app based on a radius around the user's current location. So it would be more than sufficient to get the data as JSON or XML(i read about sObjects, which would be nice too)

The app will be freely available on Google Play Store and every user should be able to see all the Workshops/Parts dealers around the world.

The problem i'm facing is that i can't find a way to fetch the data inside my app without authenticating every user with a Salesforce-Login. 
Which API is the best to use in this case?

It would be so awsome if anybody could help me with this problem.

What i tried so far: 
- SalesforceMobileSDK: If i extend SalesForceApplication i always end up with the Salesforce-Login Screen.
It seems that every client has to be authenticated for API-calls to work. I tried using the method "peekUnauthenticatedRestClient", but this method only works on full path URL's(e.g. "https://api.spotify.com/v1/search?q=James%20Brown&type=artist"), which isn't really practically for my Use-case.

- I feel like i read nearly all docs about salesforce api, but can't quite get my head around how to solve this problem, although it seems like to be a pretty common use-case.  

- would a salesforce-apex method which would select all records inside a set radius around the user's location be accessable without authentication?

Thanks for your help in advance!

Roman
Best Answer chosen by Roman Rauer
Santosh Bompally 8Santosh Bompally 8
Follow this -> 
1) Write a Restservice to expose your data. 
@RestResource(urlMapping='/Account')
global with sharing class MyRestResource {

 
    @HttpGet
    global static List<Account> doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
       List< Account>  result = [SELECT Id, Name, Business,Location FROM Account ];
        return result;
    }
  
}

2)  Create a Community and provide access to apex class and account object to the Guest user profile. 
    Samplecommunity url -> https://somedomain.cs16.force.com/communityname

3) Go to workbench and test your API using rest explorer 
    relative url ->  /services/apexrest/Account
4) Your public url will now be   https://somedomain.cs16.force.com/communityname/services/apexrest/Account 

Mark as Best Answer if it helps. 

Thanks, 
Santosh 

 
Nick Valeriote 9Nick Valeriote 9 
Hi SF Dev Community,

We're looking to implement the deliverability settings in our org (DKIM, SPF, etc.).  

If we start by making these updates in Sandbox, as not to affect our live production environment and users' daily actvities (e.g. workflow email alerts, etc.), is testing this in sandbox a reliable way to see if our settings (in SFDC and on our server) are working properly (e.g. test activities that generate email notifications), or does this all need to be done in production?

I'm wondering if our sandbox domain and IP, being different from production, will yield different results, or if that's a non factor?

Thanks.
Nick
Best Answer chosen by Nick Valeriote 9
ShirishaShirisha (Salesforce Developers) 
Hi Nick,

Greetings!

The domain will be same in the Sandbox and Production and I would suggest you to test the functionalities in sandbox first before making any changes to the live environments.

Please mark it as best answer if it helps you to fix the issue.

Thank you!

Regards,
Shirisha Pathuri 
TilluTillu 

I am working in enterprise edition. As winter 14 changed... i am unable to see the option reset security token . In devoloper edition it is visible. So from Enterprise edition i am unable to find.

Best Answer chosen by Admin (Salesforce Developers) 
hitesh90hitesh90

Hi,

 

below is the steps to find Reset security token in "Enabled Improved Setup User Interface".

 

Step 1. Go to Your Name --> My Settings

Step 2. select Personal | Reset My Security Token

 

Here you can find the option "Reset Security Token".

 

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/

SimmoSimmo 
Is there any way of displaying a picklist within an aura datatable?

I've read that only certain data types can be used within a datatable, but there must be a way of displaying a picklist or something similar where the user can select a value from a list of values?

Anybody managed to do this?
 
Best Answer chosen by Simmo
Khan AnasKhan Anas (Salesforce Developers) 
Hi Simmo,

Greetings to you!

As of now, we can not do that. There's an idea that is active on the success community with a similar discussion for which you can upvote so that it gets available in the future.

https://success.salesforce.com/ideaView?id=0873A000000PZJ4QAO

As an alternative, you would need to implement a custom HTML data table if you wanted to have this feature available. 
Or You can change the type of the picklist column from the picklist to button. On button press, open a modal that fetches and displays the picklist values.

Please refer to the below links which might help you further with the above requirement.

http://www.sfdcpanda.com/lightning-datatable-with-picklist-select-powered-in-edit-mode/

https://github.com/dineshdk/lightning-datatable-with-picklist-select-powered-in-Edit-Mode

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Arnie UArnie U 
Hi all,

I have extensively searched the communities and blog regarding this but am still getting an error:

"Challenge Not yet complete... here's what's wrong:
We can't validate the 'Create Seed Bank Agencies' node was created correctly. Check the required fields, field types, node name, and alias are correct."

I have created the Agency Detail Dataset, Completed the Dataflow, and Created the Lens:
Mosaic App
dataflowlense
{
  "Filter Agency Records": {
    "action": "filter",
    "parameters": {
      "filter": "IsAgency:EQ:TRUE",
      "source": "ID Agency Records"
    }
  },
  "Load Account": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "AccountNumber"
        },
        {
          "name": "Name"
        },
        {
          "name": "Phone"
        },
        {
          "name": "ShippingCity"
        },
        {
          "name": "ShippingCountry"
        },
        {
          "name": "ShippingState"
        },
        {
          "name": "ShippingPostalCode"
        },
        {
          "name": "ShippingStreet"
        }
      ],
      "object": "Account"
    }
  },
  "Create Seed Bank Agencies": {
    "action": "sfdcRegister",
    "parameters": {
      "name": "Seed Bank Agencies",
      "alias": "seed_bank_agencies",
      "source": "Filter Agency Records"
    }
  },
  "Add Agency Fields": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "AccountNumber"
      ],
      "left": "Load Account",
      "left_key": [
        "AccountNumber"
      ],
      "right_select": [
        "Currency",
        "Acres",
        "Latitude",
        "Longitude",
        "Region",
        "SubRegion"
      ],
      "right": "Load Agency Detail",
      "relationship": "AgencyDetail",
      "operation": "LookupSingleValue"
    }
  },
  "Load Agency Detail": {
    "action": "edgemart",
    "parameters": {
      "alias": "Agency_Detail"
    }
  },
  "ID Agency Records": {
    "action": "computeExpression",
    "parameters": {
      "source": "Add Agency Fields",
      "mergeWithSource": true,
      "computedFields": [
        {
          "name": "IsAgency",
          "saqlExpression": "case when Phone is not null then \"TRUE\" else \"FASLE\" end",
          "label": "IsAgency",
          "type": "Text"
        }
      ]
    }
  }
}
I have created 3 separate Einstein Dev Orgs tried more than 10+ times deleting recreating and still am encountering this issue. 

Can someone shed light on what I'm missing?
Best Answer chosen by Arnie U
Arnie UArnie U

Was able to solve this issue.
Error can't validate the 'Create Seed Bank Agencies' node was created correctly. Check the required fields, field types, node name, and alias are correct.

Fix: The issue is with the file (Agency Detail.txt) imported. While importing change the Longitude and Latitude data type from Measure to Dimension and do the required modification in the dataflow to report the Agency Detail file into this.

Thomas MillerThomas Miller 
Introduction
Hi everyone and thanks for stopping by! I'd like someone with a bit more knowledge and experience to do their best to asist me here if possible, but I also would like to state I do not want to be spoon fed. Pointing me in the right direction would be the general idea, and maybe a line or 2 of code on specifified sections. As the entire problem will end up being under 10 lines, I would like to be able to solve parts I can once key issues are addressed. Thank you all in advance for your time and contributions!

Problem Description
Write an Apex Trigger so each time a new Review record, API Review__c, is created, the related Media, API Media__c, has its field, API Reviews_Completed__c, incremented by 1.

Other Relevant Information & Thoughts
  • the parent record is API Media__c
  • the child record is API Review__c
  • there is a lookup relationship going from child-Review to parent-Media.
  • Media object has a default 0, number field, API Reviews_Completed__c
  • Ask for any other information if needed!
There are two main points I'm unsure about, so some clarification there is really what I'm looking for, in addition to the only lines of code I want. First, the part where I use __r to, at least I think, grab the id of the parent-Media record. I'm doing that because I want to use it for my SOQL query later on, the id = :recId part, but I'm not 100% sure it's correctly grabbing the Media recId for later use. The second part I'm unsure about is how I'm meant to access the Reviews_Completed__c field. This goes into the idea of taking a list and breaking it down into single objects to access their fields, which I thought I had done before without any problem. I'm not sure if my SOQL query should be a list of <Media__c> type, or a single Media__c sObject variable. If i can just do LIMIT 1, since the only record that matters is the one I'm currently saving and about to allow insertation, then I would think I don't need a list, in which case I should be able to increment it by simply doing sObject.FieldToIncrement++; My code is below and includes the list based case since I've explained the other way I had imagined it may work. Neither are working. Again, any help is much appreciated!

Code (gives index out of bounds error - System.QueryException: List has no rows for assignment to SObject - on SOQL query below)
As far as the error goes, I figure it's because the query gives the id field in addition to what I'm asking for, but if a list is required, please explain how I then go about taking that object out of the list in order to access the object's Reviews_Completed__c API to increment it.
trigger testTrig on Review__c (before insert) {
	
	// Following should also check every Review__c object r, in Trigger.New, and
	// if the API Review_Submission_Date__c API is empty, put the current date - this part works
    // This portion wasn't mentioned above but it's in my code as part of the exercise I'm working on.

    //To hold Media sObj rec ids
	List<Id> recId = new List<Id>();

// Loop to both add all Media ids to a list as well as change a blank submission date to today's date.
	for (Review__c r : Trigger.New) {
        recId.add(r.Media__r.id);
        if (r.Review_Submission_Date__c == null)
			r.Review_Submission_Date__c = Date.today();
    }
    
// Now that all Media ids are listed, query for 1 record such that the query result is
// of Media type and has an id that is also part of Trigger.New, meaning in list recId
// The only needed field is Reviews_Completed__c, which is going to be incremented by 1
// for each (API) Review__c record creation.
    Media__c m = [SELECT id, Reviews_Completed__c FROM Media__c
                  WHERE id IN :recId LIMIT 1];
    m.Reviews_Completed__c++;
    insert m;
    
}

Best,
Tom



 
Best Answer chosen by Thomas Miller
Thomas MillerThomas Miller
Finally solved with the following new code:

trigger testTrig on Review__c (before insert) {
    /*
     * The objective of this Trigger is to modify a Review record just
     * prior to insert and 1) change a blank date to today's date and
     * 2) update the parent Media record's Reviews_Completed field
     * to 1 higher than its current value.
     */
    
    //Create list of type Id to hold ids of Review obj parent record
    List<Id> id = new List<Id>();
    
    //Iterate through all Review obj within trigger
    for (Review__c r : Trigger.New) {
        
        //Add the Media__c field, the id of the parent, of each Review__c in trigger to list
        id.add(r.Media__c);
        
        // Assign today's date to the Review__c obj in the trigger
        // If the Review Submission Date field is empty, assign today's date
        if (r.Review_Submission_Date__c == null)
            r.Review_Submission_Date__c = Date.today();
    }
    
    //Query for the desired Media records where the id of the
    //record found matches the id of the records in the trigger, and our list
    List<Media__c> m = [SELECT Reviews_Completed__c FROM Media__c WHERE id = :id];
    
    //Increment field of the only Media obj in our list, thus index 0, and update the record
    m[0].Reviews_Completed__c++;
    update m;
}

:)

Best,
Tom
Anupama@28Anupama@28 
Hi,

We have a requirement where we need to update the communty user contact details, Is there a way to get the logged in community user information either through lightning component or community builder page or site.com page etc....

I have tried the below

> Created a VF page to get current user information and related contact information
> Created site and given link to the above VF page
> Created a community builder page and given llink to the above site

Here, If i hardcode the contactId in VF page / apex then its working fine but our requirement is to get the current logged in community user info and then fetch his/her contactId.
When i run this as community user the first step i.e. fetching user details itself is failing. 

Please help me to get the requirement done
thanks in advance.

Thanks,
anupama
 
Best Answer chosen by Anupama@28
sfdcMonkey.comsfdcMonkey.com
hi anupama 
in your apex class you can get current login user contact info by using below code 
id userId = UserInfo.getUserId();
User u = [select id, contactId from User where id = : userId];
id getContactId = u.contactId;
system.debug('getContactId' + getContactId);
i hope it helps you.
Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper soltuions for others
thanks 

http://sfdcmonkey.com  (http://sfdcmonkey.com )