• Dippan Patel
  • NEWBIE
  • 140 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 33
    Questions
  • 20
    Replies
Hi All, 

I want to create a trigger based on user's input after they install my managed package. Can anybody please explain in detail on what are the possible solutions for this? 

I did look at one solution: 
https://salesforce.stackexchange.com/questions/155868/dynamic-trigger-creation-from-managed-package/271472  (https://salesforce.stackexchange.com/questions/155868/dynamic-trigger-creation-from-managed-package/271472) but I need more detailed insight on this one or any other solution, if anybody can provide, please.

Thank you! 

 
Hi All, 

I have a visualforce page with Lightning UI. There is a "Convert Lead" link in this page. 

When clicked on this link, it is supposed to open native salesforce convert functionality. (Code below)
 
url = '/lead/leadconvert.jsp?id=' + recordId 

 if( (typeof sforce.one != 'undefined') && (sforce.one != null) ){
                if(recordId != null && recordId != ''){
                    sforce.one.navigateToURL(url);
                }
} 

else if(sforce.console.isInConsole()){
                sforce.console.openPrimaryTab(null, url, true);
}

 else {
      window.open(url);
  }



In Lightning Mode, it opens a classic visualforce page. How do I open Lightning Convert Popup (Standard)? 
Hi, 

I have a trigger that is making a callout after insert. The trigger is failing with the exception "Callout loop not allowed" only in case when lead is created by LMA. For rest of the cases it is working fine. Is there any workaround or solution for the issue? 
 
//Test Code 

trigger testTrigger on Lead (after insert) 
{ 
	for (Lead lead : Trigger.new) { 
		//call TestClass.testCallout()  
	} 
}
public class TestClass { 
	
	@future(callout=true) 
	public static void testCallout() { 
		Http http = new Http(); 
		HttpRequest req = new HttpRequest(); 
		req.setMethod('POST'); 
		req.setHeader('Content-Type', 'application/json'); 
		req.setEndpoint('https://testendpiont.com'); 
		req.setBody(body); 
		HTTPResponse res = http.send(req); 
	}
}



 
Hi All, 

How do I save the dependent picklist with no value even though it is required using Apex. 

Below is my visualforce page and controller code:
<apex:pageBlockSection title="Content Section" columns="1">

      <apex:pageBlockButtons >
	    <apex:commandButton action="{!SaveRecord}" value="Save"/>
            <apex:commandButton action="{!cancel}" value="Cancel"/>
     </apex:pageBlockButtons>

     <apex:inputField id="Street__c" label="Street " value="{!Street__c}"/>
     <apex:inputField id="City__c" label="City " value="{!City__c}"/>
      <apex:inputField id="State__c" label="State " value="{!State__c}"/> // dependent field
      <apex:inputField id="Country__c" label="Country " value="{!Country__c}"/> //controlling field
      
 </apex:pageBlockSection>


//Controller 
public class Test{

public Test(ApexPages.StandardController sc)
    {
        obj = (TestAccount__c) sc.getRecord();
}

public ApexPages.PageReference SaveRecord()
{
        try{
            insert obj;
            PageReference pr = new PageReference('/' + Obj.id);
            return pr;
        }
        catch (Exception e){
            System.debug(LoggingLevel.ERROR, e.getMessage());
            ApexPages.addMessages(e);
            return null;
        }
}
}

oth Country__c and State__c fields are required fields in field definition. The above code gives error "Required fields missing : [State]"  incase of countries with no states values. 
Hi All, 

I am having a simple visualforce page code creates a record of an object. The state and country fields are picklist and state is dependent on Country. Below inputfield tag shows proper dependency when fields are displayed but errors on save if state is null. 
 
<apex:pageBlockSection title="Content Section" columns="1">

      <apex:pageBlockButtons >
	    <apex:commandButton action="{!SaveRecord}" value="Save"/>
            <apex:commandButton action="{!cancel}" value="Cancel"/>
     </apex:pageBlockButtons>

     <apex:inputField id="Street__c" label="Street " value="{!Street__c}"/>
     <apex:inputField id="City__c" label="City " value="{!City__c}"/>
      <apex:inputField id="State__c" label="State " value="{!State__c}"/>
      <apex:inputField id="Country__c" label="Country " value="{!Country__c}"/>
      
 </apex:pageBlockSection>

Controller code: 
 
public ApexPages.PageReference SaveRecord()
{
        try{
            insert obj;
            PageReference pr = new PageReference('/' + Obj.id);
            return pr;
        }
        catch (Exception e){
            System.debug(LoggingLevel.ERROR, e.getMessage());
            ApexPages.addMessages(e);
            return null;
        }
}


If Country has no state value, the above code gives error Required fields are missing: [State] on Save. 

 
Hi, 

I have a below list: 

List<Sobject> sObj =
Sobject: (Test_Lead_Sources__c:{Id=null, OwnerId=005d0000003vn6BAAQ, IsDeleted=false, Name=test, CreatedDate=null, CreatedById=null, LastModifiedDate=null, LastModifiedById=null, SystemModstamp=null, LastViewedDate=null, LastReferencedDate=null, Primary_Source__c=test, Active__c=false})

It can have any number of records here. 

Plus this can have any custom SObject. 

I want to get the name of Custom Object here which is Test_Lead_Sources__c and list of all the records in it. 

How do I convert this list to map in such a way that I can get name of SObject? Or what is the other possible way? 
 
Hi All, 

I want to create a lightning component that should be used for any custom object for creating records of that objects. 

So that lightning component should automatically grab the custom object name when user selects the object from the list of available object, component should be automatically created. then when user clicks on new button, it should get the pagelayout and field information based on user profile and user should be able to create a record using that. 

Is there any possible way for this and if yes, what are the alternatives? 

Thank you,
Dippan 
Hi All, 

I am using Source Code Scanner for scanning my code. But it isn't identifying all the issues that come with Salesforce's security report. 

How do I identify all the issues before submitting my app again? 

Thank you. 
Hi All, 

My page is being displayed in 1/5th part of screen with scroll bars and not utilizing the entire screen for display. Here the view: 
User-added image

Any idea why? 

Thank you
Hi All, 

I am using visualforce page in lightning for creating a new record. In case of Lightning Console, the record gets saved and open up in a new tab, the current tab with the create record visualforce page remains as it is. 

Here is my sample code: 
<apex:commandButton action="{!customsave}" value="save"  onComplete = "testmethod();"> 

testmethod(){
    //get the record Id (format: "/recordid")
sforce.one.navigateToURL(recordid);
}


How do I close the current tab before the new tab is open? I tried salesforce's console - closeTab() but it doesn't seem to be working. 

Thank you!
Hi All, 

I have enabled Salesforce Lightning Account AutoFill from Setup --> Account Settings --> Enable Automated Account Fields * for autopolulating Account Name, Website, Phone and Address information. 

Is there any way I can include this autopopulation and dropdown when user's type in Account name in Custom Visualforce page for new Account creation? 

Thank you,
Dippan 
 
Hi All, 

I have a custom visualforce page and custom controller for entering a record. 

When I click on Save and New button, it works fine the first time but I again fill out the record details and click on the Save and New button, it goes in infinte loop and doesn't redirect to new record page. The record gets saved though. Just not redirected. 

P.S. Classic works fine, The visualforce page uses lightning style sheets in Lightning mode. The issue is in Lightning. 

Below is my code 
<apex:form >

<apex:actionfunction name="action_onSaveAndNew" action="{!onSaveAndNew}"  />

</apex:form>


Controller: 

public virtual PageReference onSaveAndNew2(){

				//save record
				String s = '/' + ('' + object.subString(0, 3) + '/e?';
				System.debug(loggingLevel.error, 'String s:    ' + s);
				ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.Info, s));
				PageReference page = new PageReference(s);
				page.setRedirect(true);
				return page;
			
		}

Any idea why it is not redirecting the second time? 

Thank you.  
Hi, 

I am using LightningRecordEdit Form. All the fields are displayed correctly in this format 
 
<lightning:inputField fieldName="{!field.apiName}" class="uiInput uiInput--default"/>


However,
I am getting the error when State and Country picklist is enabled in org. 

Both Picklists are disabled as there is no picklist value available.

Error: 
inputField.js: Could not find picklist values for field [StateCode] 
inputField.js: Could not find picklist values for field [CountryCode]


Can anybody please help me with the above issue? 

Thank you. 
Hi, 

I am using LightningRecordEdit Form. All the fields are displayed correctly in this format 
 
<lightning:inputField fieldName="{!field.apiName}" class="uiInput uiInput--default"/>

However,
I am getting the error when State and Country picklist is enabled in org. 

Both Picklists are disabled as there is no picklist value available.

Error: 
inputField.js: Could not find picklist values for field [StateCode]

inputField.js: Could not find picklist values for field [CountryCode]

Can anybody please help me with the above issue? 

Thank you. 
 
Hi, 

I want to run a SourceCode scan for my latest version of the package. But whenever I login to scanner and select the org id and package id, I cannot find the latest version in the dropdown. 

My latest version should be something like 1.375 and in the dropdown I have 1.325, 1.324, 1.323. 

What can be reason for this? 

Thank you,
Dippan 
Hi, 

I want to get recordtypeId and recordtypeName in Sobject if that exists.. For example, 
List<RecordType> recordTypeList;
try{
    recordTypeList = [select Id,Name from RecordType where sObjectType = 'Account'];
    System.debug('recordTypeList' + recordTypeList);
	if(!recordTypeList.isEmpty()){
        System.debug('inside if recordTypeList');
    	Account existingAccount = [select Id,RecordTypeId,RecordType.Name from Account where Id = '0010r00000xxxx'];
        System.debug('existingAccount' );
    }                        
}
catch(Exception e){
           System.debug(LoggingLevel.ERROR, 'Exception:  ' + e.getMessage());
}

The above code gives compilation error, 

Line: 7, Column: 32
select Id,RecordTypeId,RecordType.Name from ^ ERROR at Row:1:Column:11 No such column 'RecordTypeId' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.


What should be the right approach for the above scenario? 

Thank you! 
Hi All, 

Can anybody provide me a link to a managed package that might have deprecated fields on either of Leads or Contacts or Accounts? 

I've installed several free apps from Appexchange but no luck yet. 

If you know any, can you please let me know? 

Thank you,
Dippan 
Hi All, 

Is there a way to get all the deprecated fields of managed package from Lead? 

I have many fields on page layouts of Leads which are deprecated by the managed package. I want to get a list of all such fields using apex. 
Hi,
 
I have After Update Trigger with two dynamic filter criteria and they are in "OR". 
Example: If Lead Source Data Value Changes ---> process record 
OR
If Email Opt Out Data Value Changes --> process record. 

Now, I also have a workflow with condition on any update on record. 
Example: If Email Opt out is FALSE, then change it to TRUE. 

Steps of Execution: 
1. If you change Lead Source manually, trigger fires. 
2. Workflow fires to change Email Opt Out to TRUE. 
3. And Trigger fires again. 

I only want my Trigger to fire once. How do I prevent trigger executing twice without changing workflows and filter criteria?

Thank you.  
Hi, 

I have a package which is due for it's security review. However I'm not ready to release a new version on appexchange yet. Can I send the same package for periodic review? Or is it necessary to have a newer version of package? 

Thank you
Hi All, 

I am using Source Code Scanner for scanning my code. But it isn't identifying all the issues that come with Salesforce's security report. 

How do I identify all the issues before submitting my app again? 

Thank you. 
Hi, 

If I install a managed package for admin and the package has triggers on after-insert  after-update and other classes. Now if a record is created by a user who do not have access to that trigger and classes, will it execute after insert and after update trigger?

Thanks!
Hi All, 

How do I save the dependent picklist with no value even though it is required using Apex. 

Below is my visualforce page and controller code:
<apex:pageBlockSection title="Content Section" columns="1">

      <apex:pageBlockButtons >
	    <apex:commandButton action="{!SaveRecord}" value="Save"/>
            <apex:commandButton action="{!cancel}" value="Cancel"/>
     </apex:pageBlockButtons>

     <apex:inputField id="Street__c" label="Street " value="{!Street__c}"/>
     <apex:inputField id="City__c" label="City " value="{!City__c}"/>
      <apex:inputField id="State__c" label="State " value="{!State__c}"/> // dependent field
      <apex:inputField id="Country__c" label="Country " value="{!Country__c}"/> //controlling field
      
 </apex:pageBlockSection>


//Controller 
public class Test{

public Test(ApexPages.StandardController sc)
    {
        obj = (TestAccount__c) sc.getRecord();
}

public ApexPages.PageReference SaveRecord()
{
        try{
            insert obj;
            PageReference pr = new PageReference('/' + Obj.id);
            return pr;
        }
        catch (Exception e){
            System.debug(LoggingLevel.ERROR, e.getMessage());
            ApexPages.addMessages(e);
            return null;
        }
}
}

oth Country__c and State__c fields are required fields in field definition. The above code gives error "Required fields missing : [State]"  incase of countries with no states values. 
Hi All, 

I am having a simple visualforce page code creates a record of an object. The state and country fields are picklist and state is dependent on Country. Below inputfield tag shows proper dependency when fields are displayed but errors on save if state is null. 
 
<apex:pageBlockSection title="Content Section" columns="1">

      <apex:pageBlockButtons >
	    <apex:commandButton action="{!SaveRecord}" value="Save"/>
            <apex:commandButton action="{!cancel}" value="Cancel"/>
     </apex:pageBlockButtons>

     <apex:inputField id="Street__c" label="Street " value="{!Street__c}"/>
     <apex:inputField id="City__c" label="City " value="{!City__c}"/>
      <apex:inputField id="State__c" label="State " value="{!State__c}"/>
      <apex:inputField id="Country__c" label="Country " value="{!Country__c}"/>
      
 </apex:pageBlockSection>

Controller code: 
 
public ApexPages.PageReference SaveRecord()
{
        try{
            insert obj;
            PageReference pr = new PageReference('/' + Obj.id);
            return pr;
        }
        catch (Exception e){
            System.debug(LoggingLevel.ERROR, e.getMessage());
            ApexPages.addMessages(e);
            return null;
        }
}


If Country has no state value, the above code gives error Required fields are missing: [State] on Save. 

 
Hi All, 

I am using Source Code Scanner for scanning my code. But it isn't identifying all the issues that come with Salesforce's security report. 

How do I identify all the issues before submitting my app again? 

Thank you. 
Hi All, 

I have a custom visualforce page and custom controller for entering a record. 

When I click on Save and New button, it works fine the first time but I again fill out the record details and click on the Save and New button, it goes in infinte loop and doesn't redirect to new record page. The record gets saved though. Just not redirected. 

P.S. Classic works fine, The visualforce page uses lightning style sheets in Lightning mode. The issue is in Lightning. 

Below is my code 
<apex:form >

<apex:actionfunction name="action_onSaveAndNew" action="{!onSaveAndNew}"  />

</apex:form>


Controller: 

public virtual PageReference onSaveAndNew2(){

				//save record
				String s = '/' + ('' + object.subString(0, 3) + '/e?';
				System.debug(loggingLevel.error, 'String s:    ' + s);
				ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.Info, s));
				PageReference page = new PageReference(s);
				page.setRedirect(true);
				return page;
			
		}

Any idea why it is not redirecting the second time? 

Thank you.  
Hi, 

I want to run a SourceCode scan for my latest version of the package. But whenever I login to scanner and select the org id and package id, I cannot find the latest version in the dropdown. 

My latest version should be something like 1.375 and in the dropdown I have 1.325, 1.324, 1.323. 

What can be reason for this? 

Thank you,
Dippan 
Hi All, 

Can anybody provide me a link to a managed package that might have deprecated fields on either of Leads or Contacts or Accounts? 

I've installed several free apps from Appexchange but no luck yet. 

If you know any, can you please let me know? 

Thank you,
Dippan 
Hi All, 

Is there a way to get all the deprecated fields of managed package from Lead? 

I have many fields on page layouts of Leads which are deprecated by the managed package. I want to get a list of all such fields using apex. 
//Visualforce page for pageBlockTable

<apex:page standardController="Loan__c" extensions="AmoSchedRelatedListExtension">
    <apex:pageBlock title="">
        <apex:pageBlockTable value="{!Loan__c.amortization_line_items__r}" var="ali">
            <apex:column value="{!ali.Period__c}"/>
            <apex:column value="{!ali.Month__c}"/>
            <apex:column value="{!ali.Principal_Balance__c}"/>
            <apex:column value="{!ali.Monthly_Payment1__c}"/>
            <apex:column value="{!ali.Interest__c}"/>
            <apex:column value="{!ali.Principal_Payment__c}"/>
            <apex:column value="{!ali.Consulting_Fee__c}"/>
            <apex:column value="{!ali.Adjusted_Principal__c}"/>
            <apex:column value="{!ali.Adjusted_Consulting_Fee__c}"/>
            <apex:column value="{!ali.Total_Payment__c}"/>
            <apex:column value="{!ali.Remaining_Principal_Balance__c}"/>
            <apex:column value="{!ali.Interest_Payments_Received__c}"/>
            <apex:column value="{!ali.Consulting_Fee_Payments_Received__c}"/>
            <apex:column value="{!ali.Principal_Payments_Received__c}"/>
            <apex:column value="{!ali.Total_Payments_Received__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>
 
//Apex Class attempting to order the block table in ascending order by Period

public with sharing class AmoSchedRelatedListExtension
{
    private final Id loanId;
    public List<Amortization_Line_Item__c> alis { get; set; }
 
    public AmoSchedRelatedListExtension(ApexPages.StandardController stdController)
    {
        loanId = stdController.getId();
        alis = [select Id
                              ,Period__c
                              ,Month__c
                              ,Principal_Balance__c
                              ,Monthly_Payment1__c
                              ,Interest__c
                              ,Principal_Payment__c
                              ,Consulting_Fee__c
                              ,Adjusted_Principal__c
                              ,Adjusted_Consulting_Fee__c
                              ,Total_Payment__c
                              ,Remaining_Principal_Balance__c
                              ,Interest_Payments_Received__c
                              ,Principal_Payments_Received__C
                              ,Consulting_Fee_Payments_Received__c
                              ,Total_Payments_Received__c
                     from Amortization_Line_Item__c
                   where Loan__c =:loanId
               order by Period__c ASC];
    }
}
Hi everyone,

I'm attempting to add a visualforce page to a lightning record page that displays the related Amortization Line Items of a Loan. Both Loan and Amortization Line Item are custom objects. My intent is to use apex:pageBlockTable to display the related list with more than the standard 10 columns (if there is a better way to achieve this, please  recommend).

As you can see my code above, I have the visualforce page and an apex class which I was hoping would correctly order by period ascending (starting at 1 or 0, depending on the loan). 

On one record, it almost worked but it started at period 4, listed the remaing rows correctly until the final period 36 and then just had no order to it for periods 2, 3, and 1. Other records just order by Period descending.

Any help is much appreciated. Thank you!
User-added image
User-added image
Hi All, 

I have a managed package connected to my production org - where licensing is setup. 
​​​​
I have a user who has installed the package which created a License in my org. Even though I upgrade the license, user still sees it as expired. Below is the screenshot of the license in users org and expiration date in my prod org. 

Any idea why it is not upgrading in user's org? 
User-added imageUser-added image
Hi All, 

I have hardcoded client id and client secret in my code. Salesforce review mentioned to use protected custom settings to store sensitive information. 

So, I created a protected custom setting with two fields client id and client secret. I saved the values in it at  Default Organization Level Value. This custom setting is added to my managed package.

I am able to access it in the developer org, but if my package is installed in another org, it returns null. Below is the code used to access the client id
Access_Key__c authTokenSetting = Access_Key__c.getOrgDefaults();
String rawcryptoKey = authTokenSetting.UniqueEntry__Crypto_Key__c;
System.debug(LoggingLevel.DEBUG, 'Raw crypto key:    ' + rawcryptoKey);

 
Hi All, 

I want Salesforce instance name to add a remote site.
Below is my code: 
String host = URL.getSalesforceBaseUrl().getHost();
String server = host.split('\\.')[1];
String direct =  'https://' + server + '-api.salesforce.com';

I get proper server names such as CS10, CS94 in case of Developer orgs and production. 

However, in case of some sandboxes, I get server as visualforce.
 
Due to this the variable direct turns out to be https://visualforce-api.salesforce.com instead of https://yourdomain-api.salesforce.com

Not able to understand why? 
        
 
Hi All, 

I have a managed packaged installed in production. It works well in prod but not in full copy sandbox. What can be the issue? 

Thanks,
Dippan 
Hi Everyone, 

I want to override custom object new button with my visualforce page. After selecting the page to override on the custom object new button, I am getting the below error.  Error overriding visualforce page
​I have been hitting this error with our Trigger implementation and I could use some help in figuring out how to deal with it.

We have a managed package that we expose through the AppExchange
  • Someone installs, we get a lead created by the License Management Application within our org.
  • I have Lead Trigger that runs  "After Create"
  • The trigger is queueing an @future task to callout to “our service”
However, the LMA seems to be running in the context of a user from a different organization, and the @future call that I have is also running in this same user context.
The result is an exception:
Apex script unhandled exception by user/organization: 005x0000000xxxx/00Dx0000000xxxx
Failed to invoke future method 'public static void Report(String, String)' on class 'TriggerCallback' for job id '707i00000xxxxxx'
caused by: System.CalloutException: Callout loop not allowed
Class.TriggerCallback.Report: line 109, column 1

From my reaing online,it seems the callout is failing because it is running as the user in the LMA, which is not a user in out organization.  

Can I ignore this? Are the other scenarios that my trigger will run in the context of an external user?
Can I detect this and suppress this without trapping ALL CalloutExceptions?

Any suggestions would be much appreciated