• Pradeep Musthi 9
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 2
    Replies
I created a Permission Set that is not tied to any user License.  When I try to assign this Permission Set to a user with a Salesforce Platform license I get the error "Can't complete this operation because it would exceed the number of apps allowed by the user license. ".  Even if I go to the Permission Set and go to the Assigned Apps section and remove all the Apps, I STILL get the error when trying to assign to a Platform user.
Its A developer Edition Org and my profile consists of only one assigned app
Component Code
<aura:component controller="AccountController11">
     
	 <aura:attribute name="newAccount" type="Account"
         default="{ 'sobjectType': 'Account',
                        'Name': '',
                        'Type': '',
                        'Industry': '',
                        'ParentId':'',
                        
                   }"/>
    
    <aura:attribute name="Type" type="List" />
     <aura:handler name="init" value="{!this}" action="{!c.loadOptions}" />
    <force:outputField aura:id="accountLookupOutput" value="{!v.newAccount.ParentId}" class="slds-hide"></force:outputField>
    <aura:attribute name="accounts" type="Account[]"/>
   
    <form class="slds-form--stacked">
        <lightning:input aura:id="accountform" label="Account Name"
                             name="Accountname"
                             value="{!v.newAccount.Name}"
                             required="true"/>
        <lightning:select name="select" label="Select a Account Type" required="true" messageWhenValueMissing="Did you forget to select Account Type?" value="{!v.newAccount.Type}">
             <option value="">-- None --</option>
             <aura:iteration items="{!v.Type}" var="T1">
            <option value="{!T1}" text="{!T1}"></option>
            </aura:iteration>
    </lightning:select>
        <force:inputField aura:id="accountLookup" value="{!v.newAccount.ParentId}"></force:inputField>
    <lightning:button label="Create Account" 
                              class="slds-m-top--medium"
                              variant="brand"
                              onclick="{!c.clickCreate}"/>
    </form>
</aura:component>

Controller Code
({
	loadOptions: function(component, event, helper) {
	var action=component.get("c.accountType");
    action.setCallback(this, function(response){
     component.set("v.Type",response.getReturnValue())
        });
        $A.enqueueAction(action);
	},
    clickCreate : function(component, event, helper) {
		var newAccount=component.get("v.newAccount");
        console.log(newAccount);
        if($A.util.isEmpty(newAccount.Name) || $A.util.isUndefined(newAccount.Name)){
            alert(' Name is Required');
            return;
        }
        
        
        console.log("Create Account: " + JSON.stringify(newAccount));
        var b=JSON.stringify(newAccount);
        console.log("Create Account:"+JSON.parse(b));
        helper.createAccount(component,newAccount);
	}
    
})

Helper Code​
({
	createAccount: function(component, acc) {
        var action = component.get("c.saveAccount");
        console.log(acc);
        action.setParams({
            "acc1": acc
            
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var accounts = component.get("v.accounts");
                accounts.push(response.getReturnValue());
                component.set("v.accounts", accounts);
            }
        });
        $A.enqueueAction(action);
    }    
})

This Code is working only upto the page,but its not saving the the account when ever i click the create account button,but if i remove the force inputfield the account is getting created.
Can anyone help me with test class for following controller
controller code
public class InsertLeadController {

public String statusOptions { get; set; }
public String comapany { get; set; }
public String mobile { get; set; }
public String firstName{get;set;}
public String lastName{get;set;}
public Lead l ;

public List<SelectOption> getItems() {

List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('--None--','--None--'));
options.add(new SelectOption('Open – Not Contacted','Open – Not Contacted'));
options.add(new SelectOption('Working – Contacted','Working – Contacted'));
options.add(new SelectOption('Closed – Converted','Closed – Converted'));
options.add(new SelectOption('Closed – Not Converted','Closed – Not Converted'));
return options;
}
public InsertLeadController()
{
    l=new Lead();
}
public PageReference submitLead() {

//l.FirstName=firstName;
//l.LastName=lastName;
l.FirstName=firstName;
l.LastName=lastName;
l.Company=comapany;
l.MobilePhone=mobile;
l.Status=statusOptions;
insert l;
return null;
}
}
VfPage Code
<apex:page controller="InsertLeadController" showHeader="false">

<script type="text/javascript">
function validate()
    {
        if(document.getElementById('{!$Component.LF.LDB.Lname}').value == '' || document.getElementById('{!$Component.LF.LDB.comp}').value == '')
        {
            alert("LAST NMAE & Company are requird fields");
        }
        
        else
        {
            CallsubmitLead();
            alert("Account has been inserted");
        }
    }
    
 </script>
    
 <apex:form id="LF">
 <apex:actionFunction action="{!submitLead}" name="CallsubmitLead" reRender="LDB"/>  
 <apex:pageBlock title="Lead Form - Enter lead details" id="LDB"> 
  <table>
  <tr>
  <td><apex:outputText value="First Name"/></td>
  <td><apex:inputText value="{!firstName}" required="true"/></td>
  </tr>  
  <tr>
  <td><apex:outputText value="Last Name"/></td>
  <td><apex:inputText value="{!lastName}" id="Lname" required="true"/></td>
  </tr>  
  <tr>
  <td><apex:outputText value="Comapany"/></td>
  <td><apex:inputText value="{!comapany}" id="comp" required="true"/></td>
  </tr>  
  <tr>
  <td><apex:outputText value="Mobile"/></td>
  <td><apex:inputText value="{!mobile}"/></td>
  </tr>  
  <tr>
  <td><apex:outputText value="Lead Status"/></td>
  <td><apex:selectList value="{!statusOptions}" required="true">
  <apex:selectOptions value="{!items}"/>
  </apex:selectList></td>
  </tr>
  </table>  
  <apex:commandButton value="Save" onclick="validate();"/> 
 </apex:pageBlock>  
  </apex:form>
</apex:page>


 
VisualForcePage 
<apex:page controller="ActionController" >
   <script type="text/javascript">
    function validate()
    {
        ClickMe();
        }
    </script>
    <apex:form id="f1">
    <apex:actionFunction action="{!Click}" name="ClickMe" rerender="pg"/>
    <apex:pageBlock id="pg">
        <apex:outputLabel value="Enter Name">
        <apex:inputText value="{!Name}" id="n1"/>
        </apex:outputLabel>
        
         <apex:commandButton value="Refresh" onclick="validate();" />
        </apex:pageBlock>
    </apex:form>
    <apex:pageBlock>
    <apex:outputText value="{!Name1}"></apex:outputText>
    </apex:pageBlock>
</apex:page>
Controller
public class ActionController {
    public String Name{Get;Set;}
    public String Name1{Get;Set;}
public PageReference Click()
{

    Name1=Name; 
    system.debug(Name1);
    return null;
}
}

The function is like, it takes input from the page and displays the same value in the output text in a pageblock,but my action function is not working
is der any fault in my code??
 
ListOfAccounts VfPage
<apex:page controller="Controller1" >
<apex:form >
<apex:PageBlock title="Account">
<apex:outputLabel value="Enter Account Name: ">
<apex:inputText value="{!AccountName}"/>
</apex:outputLabel>
<apex:commandButton value="Search" action="{!Display}"/>
    </apex:PageBlock>
<apex:pageBlock title="The list of account are" rendered="{!b2}">
<apex:outputText  value="{!Error}"></apex:outputText>    
</apex:pageBlock>
<apex:pageBlock title="The list of account are" rendered="{!b1}">   
<apex:pageBlockTable value="{!acclist}" var="b">
  
<apex:column headerValue="Action">
<apex:inputCheckbox value="{!b.Checked}"/>
</apex:column>
    <apex:column value="{!b.acc.Name}"/>

</apex:pageBlockTable>


 <apex:pageBlockButtons >
    <apex:commandbutton value="Get Details" action="{!Details}" />
        </apex:pageBlockButtons>
</apex:PageBlock>
</apex:form>
</apex:page>

SelectedAccounts VfPage
<apex:page controller="Controller1" >
<apex:pageBlock Title="Details of selected accounts are">
<apex:pageBlockTable value="{!Selected}" var="c">
    <apex:column value="{!c.id}" />
    <apex:column value="{!c.Name}"/>
    <apex:column value="{!c.type}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

Controller1-->Custom Controller
public class Controller1 {
public string AccountName{Get;Set;}
public list<waccount> acclist{Get;Set;}
public list<Account> selected{Get;Set;}
public boolean b1{Get;Set;}
public boolean b2{Get;Set;}
public string Error{Get;Set;}
public void Display()
{
    if(acclist==null)
    {
        acclist=new list<waccount>();
        list<Account> ls=[select name,type from account where name=:AccountName];
        if(ls.size()>0)
        {
        b1=true;
        for(Account a:ls)
        {
            acclist.add(new waccount(a));
        }
        }
        else
        {
            b2=true;
            Error='No Account Found with that name';
        }
    }
}
public PageReference Details()
{
    selected=new List<Account>();
    for(waccount w:acclist)
    {
        if(w.checked==true)
        {
            selected.add(w.acc);
        }
    }
    return page.SelectedAccounts;
}
public class waccount
{
    public Account acc{get;set;}
    public boolean checked{get;set;}
    public waccount(Account acc)
    {
       this.acc=acc;
       checked=false;
    }
}
}

Can Anyone help me with test class for above controller 
Here is my Code 
trigger OppAmount on Opportunity (after insert,after update,after delete,after undelete) {
if(Trigger.isInsert || Trigger.isUpdate  || trigger.isUndelete)
{
set<Id> OppId=new Set<Id>();
for(opportunity o:Trigger.new)
{
OppId.add(o.accountid);
}
Decimal i=0;
List<Opportunity> ls=[select amount from opportunity where accountid in:OppId];
List<Account> l=[select id from account where id in:OppId];
List<account> l1=new List<Account>();


for(Opportunity o:ls)
{
if(o.Amount !=null)
{
i=i+(o.Amount);
}
}
for(Account a:l)
{
a.Opportunity_Amount__c=i;
l1.add(a);
}
update l1;
}

if(Trigger.isDelete )
{
Set<Id> accid=new Set<Id>();
for(Opportunity o:Trigger.old)
{
accid.add(o.accountid);
}
List<Account> ls=[select id,Opportunity_Amount__c,(select accountid,amount from opportunities) from account where id in:accid];
list<account> ls2=new list<account>();
decimal i7;
for(Account a:ls)
{

for(opportunity o:a.opportunities)
{

i7= a.Opportunity_Amount__c - (o.Amount);
a.Opportunity_Amount__c=i7;
}

ls2.add(a);
}
update ls2;
}
}

Its Working for insert and Update,but when i delete a particular Opportunity the amount field on trigger is not updating the subtracted value instead it is updating the deleted opportunity amount value
public class a{
public static void m5()
{
set<Account> st=new Set<Account>{new Account(Name='Prade')};
st.add(new Account(Name='m'));
system.debug(st);

}
}

How To remove account name with prade using remove method of set??Is It Possible
trigger UpdateAccount2 on Account (before update) {

List<Contact> lst=new List<contact>();
List<Account> acc=[select id,phone,(select id,phone from contacts)
                    from account where id in: trigger.newmap.keyset()];
for(Account a:acc)
{

for(Contact c:a.contacts)
{

c.phone=a.phone;
system.debug(c.phone);
lst.add(c);
}
}
update lst;                    
}

This is my Code and Its not working,can anyone what's wrong in my code.
VisualForcePage 
<apex:page controller="ActionController" >
   <script type="text/javascript">
    function validate()
    {
        ClickMe();
        }
    </script>
    <apex:form id="f1">
    <apex:actionFunction action="{!Click}" name="ClickMe" rerender="pg"/>
    <apex:pageBlock id="pg">
        <apex:outputLabel value="Enter Name">
        <apex:inputText value="{!Name}" id="n1"/>
        </apex:outputLabel>
        
         <apex:commandButton value="Refresh" onclick="validate();" />
        </apex:pageBlock>
    </apex:form>
    <apex:pageBlock>
    <apex:outputText value="{!Name1}"></apex:outputText>
    </apex:pageBlock>
</apex:page>
Controller
public class ActionController {
    public String Name{Get;Set;}
    public String Name1{Get;Set;}
public PageReference Click()
{

    Name1=Name; 
    system.debug(Name1);
    return null;
}
}

The function is like, it takes input from the page and displays the same value in the output text in a pageblock,but my action function is not working
is der any fault in my code??
 
Component Code
<aura:component controller="AccountController11">
     
	 <aura:attribute name="newAccount" type="Account"
         default="{ 'sobjectType': 'Account',
                        'Name': '',
                        'Type': '',
                        'Industry': '',
                        'ParentId':'',
                        
                   }"/>
    
    <aura:attribute name="Type" type="List" />
     <aura:handler name="init" value="{!this}" action="{!c.loadOptions}" />
    <force:outputField aura:id="accountLookupOutput" value="{!v.newAccount.ParentId}" class="slds-hide"></force:outputField>
    <aura:attribute name="accounts" type="Account[]"/>
   
    <form class="slds-form--stacked">
        <lightning:input aura:id="accountform" label="Account Name"
                             name="Accountname"
                             value="{!v.newAccount.Name}"
                             required="true"/>
        <lightning:select name="select" label="Select a Account Type" required="true" messageWhenValueMissing="Did you forget to select Account Type?" value="{!v.newAccount.Type}">
             <option value="">-- None --</option>
             <aura:iteration items="{!v.Type}" var="T1">
            <option value="{!T1}" text="{!T1}"></option>
            </aura:iteration>
    </lightning:select>
        <force:inputField aura:id="accountLookup" value="{!v.newAccount.ParentId}"></force:inputField>
    <lightning:button label="Create Account" 
                              class="slds-m-top--medium"
                              variant="brand"
                              onclick="{!c.clickCreate}"/>
    </form>
</aura:component>

Controller Code
({
	loadOptions: function(component, event, helper) {
	var action=component.get("c.accountType");
    action.setCallback(this, function(response){
     component.set("v.Type",response.getReturnValue())
        });
        $A.enqueueAction(action);
	},
    clickCreate : function(component, event, helper) {
		var newAccount=component.get("v.newAccount");
        console.log(newAccount);
        if($A.util.isEmpty(newAccount.Name) || $A.util.isUndefined(newAccount.Name)){
            alert(' Name is Required');
            return;
        }
        
        
        console.log("Create Account: " + JSON.stringify(newAccount));
        var b=JSON.stringify(newAccount);
        console.log("Create Account:"+JSON.parse(b));
        helper.createAccount(component,newAccount);
	}
    
})

Helper Code​
({
	createAccount: function(component, acc) {
        var action = component.get("c.saveAccount");
        console.log(acc);
        action.setParams({
            "acc1": acc
            
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var accounts = component.get("v.accounts");
                accounts.push(response.getReturnValue());
                component.set("v.accounts", accounts);
            }
        });
        $A.enqueueAction(action);
    }    
})

This Code is working only upto the page,but its not saving the the account when ever i click the create account button,but if i remove the force inputfield the account is getting created.
VisualForcePage 
<apex:page controller="ActionController" >
   <script type="text/javascript">
    function validate()
    {
        ClickMe();
        }
    </script>
    <apex:form id="f1">
    <apex:actionFunction action="{!Click}" name="ClickMe" rerender="pg"/>
    <apex:pageBlock id="pg">
        <apex:outputLabel value="Enter Name">
        <apex:inputText value="{!Name}" id="n1"/>
        </apex:outputLabel>
        
         <apex:commandButton value="Refresh" onclick="validate();" />
        </apex:pageBlock>
    </apex:form>
    <apex:pageBlock>
    <apex:outputText value="{!Name1}"></apex:outputText>
    </apex:pageBlock>
</apex:page>
Controller
public class ActionController {
    public String Name{Get;Set;}
    public String Name1{Get;Set;}
public PageReference Click()
{

    Name1=Name; 
    system.debug(Name1);
    return null;
}
}

The function is like, it takes input from the page and displays the same value in the output text in a pageblock,but my action function is not working
is der any fault in my code??