• Dharmendra
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 1
    Likes Given
  • 7
    Questions
  • 9
    Replies
Hi,

I want to retrieve list of fields belong to record type.
Is there any way to retrieve this information using any Salesforce api.
Please suggest.
Hi

I'm trying to Get list of fields of event page layout using metadata api.
My code for the same is below:
MetadataService mBinding = new MetadataService();
mBinding.SessionHeaderValue = new sfMetaData.SessionHeader();
mBinding.SessionHeaderValue.sessionId = accessToken;
mBinding.Url = metadataURL;

var metadataType = "Layout";
var fullNames = new string[] { "Event-Event Layout" };
var readResult = mBinding.readMetadata(metadataType, fullNames);
Here, readResult doesn't give me data.
I've tried to use fullNames by appending ManagedPackage name followed by double underscore. But its not working.

Please suggest.
 

Hi,

I'm using partner api to identify the custom fields available in event page layout.
For almost all Salesforce accounts its working fine except for one which I encountered and it return the exception as below:

There is an error in XML document (1, 11638).

"The specified type was not recognized: name='VisualforcePage', namespace='urn:partner.soap.sforce.com', at layout."

The issue occurring because of visual force page to write notes after the event exists in that account. Once it has been removed then its working fine.

Please suggest, to resolve the issue without removing this visual force page.
 
Hi,

I'm receiving refresh token expired/invalid error while retrieving the new access token. This issue is occurring sometimes (as per what I've noticed it is occurring when no action is taken for last 1 day or more.) otherwise it works.
Please suggest me to solve this issue.

Below is code sample for retrieving the new access token using existing refresh token.
string grant_type = "refresh_token";
string data = "client_id={0}&refresh_token={1}&grant_type={2}&granularity={3}";
HttpWebRequest request = HttpWebRequest.Create(_loginUrl) as HttpWebRequest;
string result = string.Empty;
string param = string.Format(data, _clientId, refreshToken, grant_type, "best");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ProtocolVersion = HttpVersion.Version11;
var bs = System.Text.Encoding.UTF8.GetBytes(param);
using (Stream reqStream = request.GetRequestStream())
{
	reqStream.Write(bs, 0, bs.Length);
}
using (WebResponse response = request.GetResponse())
{
	using (var sr = new StreamReader(response.GetResponseStream()))
	{
		result = sr.ReadToEnd();
		sr.Close();
	}
}
if (!string.IsNullOrEmpty(result))
{
	var jsonSerializer = new JavaScriptSerializer();
	var tokenData = jsonSerializer.Deserialize<SalesForceAccessModel>(result);
	return tokenData.Access_Token;
}

 
Hi,

I'm working on Salesforce integration with a system and wanted to identify the default record type for a user by user id.
Default record type for a user is associated by its profile i.e. Profile of the user contain the default record type for each object.
I've searched but didn't find where and how Salesforce manages the relationship between Profile and Record type.

So far, I'm able to get the default record type for a logged in user only, using Salesforce Partner API by retrieving the sObjects.

Do we have any way to retrieve this information from Salesforce for a user (Not logged In, but have user Id) using salesforce APIs.
Please provide any idea or suggestion to resolve it.
Hi,

I'm working with Partner APIs and for integration purpose, For a Salesforce account, I've received the Sobjects and its fields.
For sOjbects: Lead, Contact, Case, Event and Account, I fetch fields details for these and found that createdbyid, CreatedDate, LastModifiedById, and LastModifiedDate fields of these objects have Createable property as true for this Salesforce account.
According to Salesforce documentation and UI, we can't modify the createable status to true for these system fields.

Is there any way to modify the createable to true for these system fields?

Please help me to identify it, as I haven't found a way for modifying it or why Salesforce Partner API return its value to true.
Hi all,
I've tried alot of solutions for this issue but when I install the package then I received an email with exception info as below:
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out.

Please find below my code:
global class PostInstallClass implements InstallHandler {
  global void onInstall(InstallContext context) {
      User u = GetUserById(context.installerId());
      try
      {
          if(!Test.isRunningTest())          UpdatePackageInstallationInfo(context.installerId(), u.Email);
      }
      catch(Exception e)
      {
          SendMessage(new String[]{'abc@xyz.com'},'Package failed to install/upgrade','Failed to install/upgraed package. ' + u.Email + ' tried to install/upgraed the package but failed because. Error Details: ' + e);
      }     
  }
    
    public User GetUserById(ID id)
    {
        User u = [Select Id, Email from User where Id =:id];
        return u;
    }
    
    @future(callout=true)
    public static void UpdatePackageInstallationInfo(String organizationId, String userEmail)
    {        
        String url = 'http://demoapi.sunapplabs.com/api/salesforce/updateinstallpackage?organizationid='+organizationId;
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint(url);
        req.setMethod('GET');
        HttpResponse responseResult = h.send(req);
        if(responseResult.getBody() == 'true')
        {            
            SendMessage(new String[]{userEmail, 'abc@xyz.com'},'Package install successful','Thanks for installing the package. Response result : '+responseResult);
        }
        else
        {
            SendMessage(new String[]{'abc@xyz.com'},'Package failed to install/upgrade','Failed to install/upgraed package. ' + userEmail + ' tried to install/upgraed the package but failed because of failure from MyAPI response. Response result : '+responseResult);
        }
    }
    public static void SendMessage(String[] toAddresses, String subject, String message)
    {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toAddresses);
        mail.setReplyTo('abc@xyz.com');
        mail.setSenderDisplayName('My Package Support');
        mail.setSubject(subject);
        mail.setPlainTextBody(message);
        Messaging.sendEmail(new Messaging.Email[] { mail }); 
    }
  }



 
Hi,

I'm working with Partner APIs and for integration purpose, For a Salesforce account, I've received the Sobjects and its fields.
For sOjbects: Lead, Contact, Case, Event and Account, I fetch fields details for these and found that createdbyid, CreatedDate, LastModifiedById, and LastModifiedDate fields of these objects have Createable property as true for this Salesforce account.
According to Salesforce documentation and UI, we can't modify the createable status to true for these system fields.

Is there any way to modify the createable to true for these system fields?

Please help me to identify it, as I haven't found a way for modifying it or why Salesforce Partner API return its value to true.
Hi all,
I've tried alot of solutions for this issue but when I install the package then I received an email with exception info as below:
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out.

Please find below my code:
global class PostInstallClass implements InstallHandler {
  global void onInstall(InstallContext context) {
      User u = GetUserById(context.installerId());
      try
      {
          if(!Test.isRunningTest())          UpdatePackageInstallationInfo(context.installerId(), u.Email);
      }
      catch(Exception e)
      {
          SendMessage(new String[]{'abc@xyz.com'},'Package failed to install/upgrade','Failed to install/upgraed package. ' + u.Email + ' tried to install/upgraed the package but failed because. Error Details: ' + e);
      }     
  }
    
    public User GetUserById(ID id)
    {
        User u = [Select Id, Email from User where Id =:id];
        return u;
    }
    
    @future(callout=true)
    public static void UpdatePackageInstallationInfo(String organizationId, String userEmail)
    {        
        String url = 'http://demoapi.sunapplabs.com/api/salesforce/updateinstallpackage?organizationid='+organizationId;
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint(url);
        req.setMethod('GET');
        HttpResponse responseResult = h.send(req);
        if(responseResult.getBody() == 'true')
        {            
            SendMessage(new String[]{userEmail, 'abc@xyz.com'},'Package install successful','Thanks for installing the package. Response result : '+responseResult);
        }
        else
        {
            SendMessage(new String[]{'abc@xyz.com'},'Package failed to install/upgrade','Failed to install/upgraed package. ' + userEmail + ' tried to install/upgraed the package but failed because of failure from MyAPI response. Response result : '+responseResult);
        }
    }
    public static void SendMessage(String[] toAddresses, String subject, String message)
    {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toAddresses);
        mail.setReplyTo('abc@xyz.com');
        mail.setSenderDisplayName('My Package Support');
        mail.setSubject(subject);
        mail.setPlainTextBody(message);
        Messaging.sendEmail(new Messaging.Email[] { mail }); 
    }
  }



 
Hi,

I want to retrieve list of fields belong to record type.
Is there any way to retrieve this information using any Salesforce api.
Please suggest.
Hi

I'm trying to Get list of fields of event page layout using metadata api.
My code for the same is below:
MetadataService mBinding = new MetadataService();
mBinding.SessionHeaderValue = new sfMetaData.SessionHeader();
mBinding.SessionHeaderValue.sessionId = accessToken;
mBinding.Url = metadataURL;

var metadataType = "Layout";
var fullNames = new string[] { "Event-Event Layout" };
var readResult = mBinding.readMetadata(metadataType, fullNames);
Here, readResult doesn't give me data.
I've tried to use fullNames by appending ManagedPackage name followed by double underscore. But its not working.

Please suggest.
 

Hi,

I'm using partner api to identify the custom fields available in event page layout.
For almost all Salesforce accounts its working fine except for one which I encountered and it return the exception as below:

There is an error in XML document (1, 11638).

"The specified type was not recognized: name='VisualforcePage', namespace='urn:partner.soap.sforce.com', at layout."

The issue occurring because of visual force page to write notes after the event exists in that account. Once it has been removed then its working fine.

Please suggest, to resolve the issue without removing this visual force page.
 
Hi,

I'm receiving refresh token expired/invalid error while retrieving the new access token. This issue is occurring sometimes (as per what I've noticed it is occurring when no action is taken for last 1 day or more.) otherwise it works.
Please suggest me to solve this issue.

Below is code sample for retrieving the new access token using existing refresh token.
string grant_type = "refresh_token";
string data = "client_id={0}&refresh_token={1}&grant_type={2}&granularity={3}";
HttpWebRequest request = HttpWebRequest.Create(_loginUrl) as HttpWebRequest;
string result = string.Empty;
string param = string.Format(data, _clientId, refreshToken, grant_type, "best");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ProtocolVersion = HttpVersion.Version11;
var bs = System.Text.Encoding.UTF8.GetBytes(param);
using (Stream reqStream = request.GetRequestStream())
{
	reqStream.Write(bs, 0, bs.Length);
}
using (WebResponse response = request.GetResponse())
{
	using (var sr = new StreamReader(response.GetResponseStream()))
	{
		result = sr.ReadToEnd();
		sr.Close();
	}
}
if (!string.IsNullOrEmpty(result))
{
	var jsonSerializer = new JavaScriptSerializer();
	var tokenData = jsonSerializer.Deserialize<SalesForceAccessModel>(result);
	return tokenData.Access_Token;
}

 
Hi,

I'm working with Partner APIs and for integration purpose, For a Salesforce account, I've received the Sobjects and its fields.
For sOjbects: Lead, Contact, Case, Event and Account, I fetch fields details for these and found that createdbyid, CreatedDate, LastModifiedById, and LastModifiedDate fields of these objects have Createable property as true for this Salesforce account.
According to Salesforce documentation and UI, we can't modify the createable status to true for these system fields.

Is there any way to modify the createable to true for these system fields?

Please help me to identify it, as I haven't found a way for modifying it or why Salesforce Partner API return its value to true.
Hi all,
I've tried alot of solutions for this issue but when I install the package then I received an email with exception info as below:
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out.

Please find below my code:
global class PostInstallClass implements InstallHandler {
  global void onInstall(InstallContext context) {
      User u = GetUserById(context.installerId());
      try
      {
          if(!Test.isRunningTest())          UpdatePackageInstallationInfo(context.installerId(), u.Email);
      }
      catch(Exception e)
      {
          SendMessage(new String[]{'abc@xyz.com'},'Package failed to install/upgrade','Failed to install/upgraed package. ' + u.Email + ' tried to install/upgraed the package but failed because. Error Details: ' + e);
      }     
  }
    
    public User GetUserById(ID id)
    {
        User u = [Select Id, Email from User where Id =:id];
        return u;
    }
    
    @future(callout=true)
    public static void UpdatePackageInstallationInfo(String organizationId, String userEmail)
    {        
        String url = 'http://demoapi.sunapplabs.com/api/salesforce/updateinstallpackage?organizationid='+organizationId;
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint(url);
        req.setMethod('GET');
        HttpResponse responseResult = h.send(req);
        if(responseResult.getBody() == 'true')
        {            
            SendMessage(new String[]{userEmail, 'abc@xyz.com'},'Package install successful','Thanks for installing the package. Response result : '+responseResult);
        }
        else
        {
            SendMessage(new String[]{'abc@xyz.com'},'Package failed to install/upgrade','Failed to install/upgraed package. ' + userEmail + ' tried to install/upgraed the package but failed because of failure from MyAPI response. Response result : '+responseResult);
        }
    }
    public static void SendMessage(String[] toAddresses, String subject, String message)
    {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toAddresses);
        mail.setReplyTo('abc@xyz.com');
        mail.setSenderDisplayName('My Package Support');
        mail.setSubject(subject);
        mail.setPlainTextBody(message);
        Messaging.sendEmail(new Messaging.Email[] { mail }); 
    }
  }



 

Hi Experts,

 

I have a custom field of type picklist in User object. I need users to change the value of this field using a custom sidebar widget. The widget just needs to have a picklist custom field with data and a save button which will save the value in the User object.

How can I possibly achieve this functionality. Please suggest.

 

Thanks & Regards,

Nitesh Saxena