• Tavva Sai Krishna
  • NEWBIE
  • 296 Points
  • Member since 2014


  • Chatter
    Feed
  • 9
    Best Answers
  • 2
    Likes Received
  • 7
    Likes Given
  • 3
    Questions
  • 96
    Replies
Hello All,
I wanted to convert Days,Hours into Minutes and populate the value in minutes field as a SUM value of all i.e. (Days(should be converted into minutes)+Hours(should be converted into minutes) +Minutes = Minutes).

Example:
I have a field Days which is populated from below formula: 
Text( FLOOR( Date_Time_Gas_Off__c - Date_Time_Gas_Riser_Commissioned__c ) )

Now, I want to populate Minutes value which should be a SUM of Days(converted to mins)+Hours(converted to mins)+Minutes for which I have a formula as shown below:

Text(FLOOR((( Date_Time_Gas_Off__c - Date_Time_Gas_Riser_Commissioned__c) *1440)*24)   //Days//
+
Text(ROUND(((Date_Time_Gas_Off__c - Date_Time_Gas_Riser_Commissioned__c )*60),0))         //Hours//
+
Text(ROUND(((Date_Time_Gas_Off__c - Date_Time_Gas_Riser_Commissioned__c )))))                 //Minutes//

When I try to execute the formula, I get an error as :
Error: Incorrect parameter type for operator '+'. Expected Number, Date, DateTime, received Text

Please assist me with the correct formula to display the value in minutes. 

Thanks in advance!

 
I have a Apex class that automatically creates a lead when certain conditions apply to case from another Org. However, the state field is a picklist and somestimes the field values from the sending org are not always in the receiving orgs picklist. How can I validate that the State received is actually in the picklist. 

My initial thought was to create a string array with all of the valid values and compare the state against that, but if the picklist changes, then my code will not be accurate. Any suggestions would be much appreciated. 
I have two lists(mainGroupLinkerIPGlist and toCopy) i am trying to remove all the values of mainGroupLinkerIPGlist from toCopy by creating a set and adding both the lists to the IPGset. below is the apex code.
 
List<Intralinks_Group_and_Contact_Links__c> mainGroupLinkerIPGlist = [SELECT Id,Intralinks_Portal_Group__c FROM Intralinks_Group_and_Contact_Links__c where Contact__c = :mainGroupLinker.Contact__c];
        //system.debug('mainGroupLinkerIPGlist =' + mainGroupLinkerIPGlist.size());

    //query all the Groups the copyFrom contact has
    if(copyFrom.Contact__c != null) {
       List<Intralinks_Group_and_Contact_Links__c> toCopy = [SELECT Id,Intralinks_Portal_Group__c FROM Intralinks_Group_and_Contact_Links__c where Contact__c = :copyFrom.Contact__c];

         system.debug('toCopy =' + toCopy.size());

         set<Intralinks_Group_and_Contact_Links__c> IPGset = New set<Intralinks_Group_and_Contact_Links__c>(toCopy);

         boolean result = IPGset.removeall(mainGroupLinkerIPGlist);
         System.assertEquals(true, result);
         system.debug('mainGroupLinkerIPGlist Count=' + mainGroupLinkerIPGlist.size());
         system.debug('IPGset count=' + IPGset.size());

when i am trying to remove all the mainGroupLinkerIPGlist values from set it is not removing and i am getting below message. System.AssertException: Assertion Failed: Expected: true, Actual: false
Hi guys,

I'm just starting to use the Lightning Design System and I dont really understand the behaviour of the grid system.
 
<div class="slds-grid slds-wrap">
   <aura:iteration items="{!v.fieldsFromObject}" var="field">
        <div class="slds-col--padded slds-size--1-of-1 slds-small-size--1-of-1 slds-medium-size--2-of-6 slds-large-size--3-of-12">
                        TEST
        </div>
    </aura:iteration>
</div>
And thats the result: 

the resulting grid
As you can see, the last content has 100% width ... my understanding is that it should be 33.33% just like the other cols.

Am I missing something here?

Cheers
Hi,
I created my first VF page and placed it in a VF section on the Opportunity page layout.  When I click to save, the page refreshes and shows me all of the apex source code.  I can't seem to figure out the best course of action to have the page reload with the saved values on the screen.  When I click on the save button in this VF section of the oppty, ?inline is added to the end of the URL.  If I remove that, the source code goes away and I'm returned to the original page.  What do I need to do to get this save working properly?  Would a retURL do the trick?

Thanks!
i have wrote this formula but it added 1 year to conformation date field so plz suggest
DATE(
year( DOJ__c )
+ floor((month(DOJ__c) + 6)/12) + if(and(month(DOJ__c)=12,6>=12),-1,0)
,
if( mod( month(DOJ__c) + 6, 12 ) = 0, 12 , mod( month(DOJ__c) + 6, 12 ))
,
min(
day(DOJ__c),
case(
max( mod( month(DOJ__c) + 6, 12 ) , 1),
9,30,
4,30,
6,30,
11,30,
2,if(mod((year(DOJ__c)
+ floor((month(DOJ__c) + 6)/12) + if(and(month(DOJ__c)=12,6>=12),-1,0)),4)=0,29,28),
31
)
)
)
Hi, I have a custom repeat list and one of the column will display different result based on certain condition:-
 
<apex:repeat value="{!Quote.QuoteLineItems}" var="qli">
                        <tr class = "stdstyle">
                            <td>{!FLOOR(count)} </td> 
                            <td>{!qli.Product2.Name}</td>
                            <td >{!IF(qli.Quote_PDS_Description__c == "Summary Only",qli.Product_Description__c,IF(qli.Quote_PDS_Description__c == "Summary & Short Details",qli.Product_Description__c +  qli.Quote_attribute_1__c ,""))} </td>
                            <td>{!qli.UnitPrice}</td>
                                
                            <apex:variable var="count" value="{!count+ 1}"/>
                        </tr>
                    </apex:repeat>
as you see from the above, i would like to have a line break between Product_Description__c & Quote_attribute_1__c instead of joining them together in 1 line. Is that possible?

Thanks.
 
Hi I have 2 objects; one custom second one is opportunity. First I created a custom object like as opportunity. But I want move fields (custom object) from to standard opportunity. In opportunity also some custom fields added. Is there any way to move fields please help me?
 
Hi,

We've been working on a trigger which creates a contract upon an Opportunity being complete and 'Closed Won'. We've managed to get the record to create and copy over important info, although we can't manage to figure the validation logic. Granted we have little apex knowledge and therefore we've attempted to put most of the logic outside the trigger and within a workflowed checkbox on the Opportunity.

However, this don't eliminate the duplication of records if the user edits a Won opportunity. I know the better versed Salesforce developer would have the list check the record doesn't exist in the first place before the trigger even starts and therefore we're reaching out hoping you guys could support us in finishing this piece of work.

Any help or advice would be gratefully appreciated. 
trigger CreateContract on Opportunity (after insert, after update) {

    List<Contract> conttoinsert = new List<Contract>();

    for (Opportunity opp : Trigger.new) {

        if (opp.StageName == 'Closed Won' && opp.RecordTypeID == '012N00000004pSi' && opp.Record_Complete__c == TRUE) {
            Contract con = new Contract();
            con.Name                  = opp.name;
            con.Account               = opp.Account;
            con.CurrencyIsoCode       = opp.CurrencyIsoCode;
            con.AccountId             = opp.AccountId;
            con.StartDate             = opp.Service_Start_Date__c;
            con.Contract_Value__c     = opp.Total_Performance__c;
            con.Description           = opp.Opportunity_Description__c;
            con.Sales_Lead__c         = opp.OwnerID;
            conttoinsert.add(con);
        } 
    }

    if ( !conttoinsert.isEmpty()) {
        insert conttoinsert;

}
}

 
I have a custom button on detail page of account object whose behaviour is "Execute Javascript" and content source is "onclick JavaScript". My query is how can i disable the button upon click on it.
I have tried with below code but no luck
{!REQUIRESCRIPT("https://code.jquery.com/jquery-3.0.0.min.js")}
$(this).addClass( 'btnDisabled' );

Also I tried with the prop, and attr methods instead of addClass. does any one has got same error!!!

Thanks and Regards,
Sai Krishna Tavva.
Hi All , getting the error while completing this module. While my application is running correctly.

Error: Challenge Not yet complete... here's what's wrong: The campingList JavaScript helper isn't saving the new record to the database or adding it to the 'items' value provider.

I am copying code for the finding the bug.

Apex Class:
public class CampingListController {
	@auraenabled
    public static List<Camping_Item__c> getItems (){
        List<Camping_Item__c> CI = [select id, name,price__c,Quantity__c,Packed__c from Camping_Item__c ];
        return CI;
    }
    @auraenabled
    public static Camping_Item__c saveItem (Camping_Item__c CampingItem){
        insert campingItem;
        return campingItem;
    }
}
CampingList.cmp
<aura:component controller="CampingListController">
    <aura:handler name = "init" value="{!this}" action = "{!c.doInit}"/>
	<aura:attribute name="items" type="Camping_Item__c[]"/>
    <aura:attribute name="er" type="boolean" default="false"/>
    <aura:attribute name="newItem" type="Camping_Item__c"    default="{ 'sobjectType': 'Camping_Item__c',
                         'Name': '',
                         'Price__c': 0,
                         'Quantity__c': 0,                         
                         'Packed__c': false
                       }"/>
    <ui:inputText value="{!v.newItem.Name}" aura:id="name" label="name"/>
    <ui:inputCheckbox value="{!v.newItem.Packed__c}" aura:id="Packed" label="Packed"/>
    <ui:inputCurrency value="{!v.newItem.Price__c}"  aura:id="Price" label="Price"/>
    <ui:inputNumber value="{!v.newItem.Quantity__c}" aura:id="Quantity" label="Quantity"/>
    <ui:button label="Create Expense" press="{!c.CreateCamping}" aura:id="button"/>
    <br/>
	<aura:iteration items="{!v.items}" var="PerItem">
        
        <c:campingListItem item="{!PerItem}" />
    </aura:iteration>
</aura:component>
CampingList.js
({
	
    doInit  : function(component, event, helper) {
		var action = component.get("c.getItems");
        action.setCallback(this, function(response){
            var state = response.getState();
           
            if (component.isValid() && state === "SUCCESS") {
           
               
                component.set("v.items", response.getReturnValue());
                 
            }
        });
        
        $A.enqueueAction(action);
	},
    
    CreateCamping : function(component, event, helper){
        
        helper.validateFields (component,component.find("name"));
        helper.validateFields (component,component.find("Price"));
        helper.validateFields (component,component.find("Quantity"));
        if(component.get("v.er") === false)
        {
            var lstItems = component.get("v.items");
            var Item = component.get("v.newItem");
            console.log('Before:'+lstItems);
            lstItems.push(Item);
            helper.CreateCampaign(component,Item);
            component.set("v.items",lstItems);  
             console.log('After:'+lstItems);
            component.set("v.newItem",{ 'sobjectType': 'Camping_Item__c',
                'Name': '',
                'Quantity__c': 0,
                'Price__c': 0,
                'Packed__c': false });
           
        }
	}
    
    
})

CampingListHelper.js
({
	
    validateFields : function (component,field) {
        
        var nameField = field;
        console.log('yes:'+nameField);
        var expname = nameField.get("v.value"); 
        if ($A.util.isEmpty(expname)){
           component.set("v.er",true);
           nameField.set("v.errors", [{message:"this field can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
    },
    
    CreateCampaign : function (component,Item){         
        var action = component.get("c.saveItem");
        action.setParams({"CampingItem":Item});
        action.setCallback(this,function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                console.log('save');
            }
        });
       $A.enqueueAction(action);        
    }
})
campingListItem.cmp
 
<aura:component >
    
   
    <aura:attribute type="Camping_Item__c" name="item" required="true"/>
    Name:
    <ui:outputText value="{!v.item.Name}" /><br/>
    Packed:
    <ui:outputCheckbox value="{!v.item.Packed__c}" /><br/>
    Price:
    <ui:outputCurrency value="{!v.item.Price__c}" /><br/>
   
    Quantity:
     <ui:outputNumber value="{!v.item.Quantity__c}" /><br/>
    
    <ui:button label="Packed!"  press="{!c.packItem}" aura:id = "Button"/> <br/>
</aura:component>

campingListItem.js
({
	    
    packItem : function(component, event, helper) {
		var pack = component.get("v.item");
        pack.Packed__c = true;
        component.set("v.item",pack);
        var btnClicked = event.getSource();
        btnClicked.set("v.disabled",true);
        
	}
    
    
})


Help me out with it.

Thanks and Regards,
Sai Krishna Tavva.


 
Hi guys, 
         I have created a class which has callout & it need to fetch the response from the google server. By using JSON parser, I am  getting the latitude & longitude values which are present in the response. For that I used Below Code to access the Latitude & longitude values
JSONParser parser = JSON.createParser(JSonText);
            double lat = null;
            double lon = null;
            while (parser.nextToken() != null)
             {
                if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && 
                    (parser.getText() == 'location'))
                    {
                       parser.nextToken(); // object start
                       while (parser.nextToken() != JSONToken.END_OBJECT)
                       {
                           String txt = parser.getText();
                           parser.nextToken();
                           if (txt == 'lat')
                               lat = parser.getDoubleValue();
                           else if (txt == 'lng')
                               lon = parser.getDoubleValue();
                       }
                    
                    }
             }

 But I was unable to write the test class which covers these lines.. My test coverage is 66% as of now.. Please Help me , in writing the test class to cover all above lines should cover....

Thanks
Hi All , getting the error while completing this module. While my application is running correctly.

Error: Challenge Not yet complete... here's what's wrong: The campingList JavaScript helper isn't saving the new record to the database or adding it to the 'items' value provider.

I am copying code for the finding the bug.

Apex Class:
public class CampingListController {
	@auraenabled
    public static List<Camping_Item__c> getItems (){
        List<Camping_Item__c> CI = [select id, name,price__c,Quantity__c,Packed__c from Camping_Item__c ];
        return CI;
    }
    @auraenabled
    public static Camping_Item__c saveItem (Camping_Item__c CampingItem){
        insert campingItem;
        return campingItem;
    }
}
CampingList.cmp
<aura:component controller="CampingListController">
    <aura:handler name = "init" value="{!this}" action = "{!c.doInit}"/>
	<aura:attribute name="items" type="Camping_Item__c[]"/>
    <aura:attribute name="er" type="boolean" default="false"/>
    <aura:attribute name="newItem" type="Camping_Item__c"    default="{ 'sobjectType': 'Camping_Item__c',
                         'Name': '',
                         'Price__c': 0,
                         'Quantity__c': 0,                         
                         'Packed__c': false
                       }"/>
    <ui:inputText value="{!v.newItem.Name}" aura:id="name" label="name"/>
    <ui:inputCheckbox value="{!v.newItem.Packed__c}" aura:id="Packed" label="Packed"/>
    <ui:inputCurrency value="{!v.newItem.Price__c}"  aura:id="Price" label="Price"/>
    <ui:inputNumber value="{!v.newItem.Quantity__c}" aura:id="Quantity" label="Quantity"/>
    <ui:button label="Create Expense" press="{!c.CreateCamping}" aura:id="button"/>
    <br/>
	<aura:iteration items="{!v.items}" var="PerItem">
        
        <c:campingListItem item="{!PerItem}" />
    </aura:iteration>
</aura:component>
CampingList.js
({
	
    doInit  : function(component, event, helper) {
		var action = component.get("c.getItems");
        action.setCallback(this, function(response){
            var state = response.getState();
           
            if (component.isValid() && state === "SUCCESS") {
           
               
                component.set("v.items", response.getReturnValue());
                 
            }
        });
        
        $A.enqueueAction(action);
	},
    
    CreateCamping : function(component, event, helper){
        
        helper.validateFields (component,component.find("name"));
        helper.validateFields (component,component.find("Price"));
        helper.validateFields (component,component.find("Quantity"));
        if(component.get("v.er") === false)
        {
            var lstItems = component.get("v.items");
            var Item = component.get("v.newItem");
            console.log('Before:'+lstItems);
            lstItems.push(Item);
            helper.CreateCampaign(component,Item);
            component.set("v.items",lstItems);  
             console.log('After:'+lstItems);
            component.set("v.newItem",{ 'sobjectType': 'Camping_Item__c',
                'Name': '',
                'Quantity__c': 0,
                'Price__c': 0,
                'Packed__c': false });
           
        }
	}
    
    
})

CampingListHelper.js
({
	
    validateFields : function (component,field) {
        
        var nameField = field;
        console.log('yes:'+nameField);
        var expname = nameField.get("v.value"); 
        if ($A.util.isEmpty(expname)){
           component.set("v.er",true);
           nameField.set("v.errors", [{message:"this field can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
    },
    
    CreateCampaign : function (component,Item){         
        var action = component.get("c.saveItem");
        action.setParams({"CampingItem":Item});
        action.setCallback(this,function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                console.log('save');
            }
        });
       $A.enqueueAction(action);        
    }
})
campingListItem.cmp
 
<aura:component >
    
   
    <aura:attribute type="Camping_Item__c" name="item" required="true"/>
    Name:
    <ui:outputText value="{!v.item.Name}" /><br/>
    Packed:
    <ui:outputCheckbox value="{!v.item.Packed__c}" /><br/>
    Price:
    <ui:outputCurrency value="{!v.item.Price__c}" /><br/>
   
    Quantity:
     <ui:outputNumber value="{!v.item.Quantity__c}" /><br/>
    
    <ui:button label="Packed!"  press="{!c.packItem}" aura:id = "Button"/> <br/>
</aura:component>

campingListItem.js
({
	    
    packItem : function(component, event, helper) {
		var pack = component.get("v.item");
        pack.Packed__c = true;
        component.set("v.item",pack);
        var btnClicked = event.getSource();
        btnClicked.set("v.disabled",true);
        
	}
    
    
})


Help me out with it.

Thanks and Regards,
Sai Krishna Tavva.


 
HI All,

        I am new to salesforce,i have one requirement if user opens the record, automatically send an email to owner so and so user opens your record.How can we acheive this functionality. Please help me.

Thanks in advance.
I have an Apex trigger setup to check the Forecast checkbox to true, and updater or insert the Company Name to BPHS. 

What should my syntax look like if I don't want this trigger to update a picklist named, License__c with the value of Distribution

I want to keep the syntax I have, but if Distribution is selected, I need the syntax to skip that record. 

Here is my current syntax: 
trigger ForceForecasting on User (before update, before insert) {
    for (User userInLoop : Trigger.new) {
        userInLoop.ForecastEnabled = true;
        userInLoop.CompanyName = 'BPHS';
    }
}

Thank you in advance!
I have one requirement like this:

When we are creating an opportunity by clicking new button :i
1:It should redirect to a new page which will have the two fields one is for selecting the record type X or Y or Z and another is for selecting type of process : A or B or C.
2:Now if select record type X and process A and click on continue it should redirect to page layout as per record type and in that page layout it should 3 fields depending on process selection A or B or C.

Can we acheive this ?please advise

Thanks
lokesh
 
Hello All,
I wanted to convert Days,Hours into Minutes and populate the value in minutes field as a SUM value of all i.e. (Days(should be converted into minutes)+Hours(should be converted into minutes) +Minutes = Minutes).

Example:
I have a field Days which is populated from below formula: 
Text( FLOOR( Date_Time_Gas_Off__c - Date_Time_Gas_Riser_Commissioned__c ) )

Now, I want to populate Minutes value which should be a SUM of Days(converted to mins)+Hours(converted to mins)+Minutes for which I have a formula as shown below:

Text(FLOOR((( Date_Time_Gas_Off__c - Date_Time_Gas_Riser_Commissioned__c) *1440)*24)   //Days//
+
Text(ROUND(((Date_Time_Gas_Off__c - Date_Time_Gas_Riser_Commissioned__c )*60),0))         //Hours//
+
Text(ROUND(((Date_Time_Gas_Off__c - Date_Time_Gas_Riser_Commissioned__c )))))                 //Minutes//

When I try to execute the formula, I get an error as :
Error: Incorrect parameter type for operator '+'. Expected Number, Date, DateTime, received Text

Please assist me with the correct formula to display the value in minutes. 

Thanks in advance!

 
Im new to sales force and I really don't know if my codes are good. But if update the Billing Address it would not update the mailing address in my Contact. can somebody point out what I'm missing? thanks
--------------------------------------------------------
trigger contactFromAccount on Account (after update) {
        ManagingAccountAndContacts begintrigger = new ManagingAccountAndContacts();
        
        if(Trigger.isbefore && Trigger.isupdate){
               begintrigger.isBeforeUpdate(trigger.new);
        }
}

---------------------------------------------------
public class ManagingAccountAndContacts {
        public void isBeforeUpdate(List<Account> accList){
            updateAddressToContacts(accList);
        }
    
        public void updateAddressToContacts(List<Account> accList){
             String accName = '';
            String contactmailingStreet = '';
            String contactmailingCity = '';
            String contactmailingState = '';
            String contactmailingPostalCode = '';
            String contactmailingCountry = '';
            
            for(Account acc:accList){
            accName = acc.Name;
               contactmailingStreet = acc.BillingStreet;  
            contactmailingCity = acc.BillingCity;
            contactmailingState = acc.BillingState;
            contactmailingPostalCode = acc.BillingPostalCode;
            contactmailingCountry = acc.BillingCountry;
            }
        
            List<Contact> contactList =[select MailingStreet,MailingCity, MailingState,MailingPostalCode,MailingCountry 
                         from Contact where Account.name Like:(accName)];
       
            for(Contact con: contactList){
                con.MailingStreet = contactmailingStreet;
             con.MailingCity =  contactmailingCity;
             con.MailingState = contactmailingState;
             con.MailingPostalCode = contactmailingPostalCode;
             con.MailingCountry = contactmailingCountry;
             
               }
        }
}

 
I have a Apex class that automatically creates a lead when certain conditions apply to case from another Org. However, the state field is a picklist and somestimes the field values from the sending org are not always in the receiving orgs picklist. How can I validate that the State received is actually in the picklist. 

My initial thought was to create a string array with all of the valid values and compare the state against that, but if the picklist changes, then my code will not be accurate. Any suggestions would be much appreciated. 
trigger stockupdate on Line_Item2__c (before insert,before update) {
List<Stock__c> sto= new List<Stock__c>();
    if(trigger.isinsert){
for(Line_Item2__c li:trigger.new){
sto.add(new Stock__c(Name=li.Product_Code__c,Product_Name__c=li.Product_Name__c,Manufacturing_Date__c=li.Manufacturing_Date__c,Batch_No__c=li.name,Expiry_Date__c=li.Expiry_Date__c,No_Of_Boxes__c=li.No_Of_Boxes__c,Pieces_Per_Box__c=li.Pieces_Per_Box__c,Manufacturer_Name__c=li.Manufacturer_Name__c,Total_No_Of_Pieces__c=li.Total_No_Of_Pieces__c)) ;           
                                  }
        insert sto;  
    }
     if(trigger.isupdate){
        for(Line_Item2__c lt:trigger.new){
            stock__c st;  
            st.Name=lt.Product_Code__c;
            st.Product_Name__c=lt.Product_Name__c;
            st.Manufacturing_Date__c=lt.Manufacturing_Date__c;
            st.Batch_No__c=lt.name;
            st.Expiry_Date__c=lt.Expiry_Date__c;
            st.No_Of_Boxes__c=lt.No_Of_Boxes__c;
            st.Pieces_Per_Box__c=lt.Pieces_Per_Box__c;
            st.Manufacturer_Name__c=lt.Manufacturer_Name__c;
            st.Total_No_Of_Pieces__c=lt.Total_No_Of_Pieces__c;
            sto.add(st);
            
            
        }
   upsert sto;
     }
}

Thanks in advance
Hi All , getting the error while completing this module. While my application is running correctly.

Error: Challenge Not yet complete... here's what's wrong: The campingList JavaScript helper isn't saving the new record to the database or adding it to the 'items' value provider.

I am copying code for the finding the bug.

Apex Class:
public class CampingListController {
	@auraenabled
    public static List<Camping_Item__c> getItems (){
        List<Camping_Item__c> CI = [select id, name,price__c,Quantity__c,Packed__c from Camping_Item__c ];
        return CI;
    }
    @auraenabled
    public static Camping_Item__c saveItem (Camping_Item__c CampingItem){
        insert campingItem;
        return campingItem;
    }
}
CampingList.cmp
<aura:component controller="CampingListController">
    <aura:handler name = "init" value="{!this}" action = "{!c.doInit}"/>
	<aura:attribute name="items" type="Camping_Item__c[]"/>
    <aura:attribute name="er" type="boolean" default="false"/>
    <aura:attribute name="newItem" type="Camping_Item__c"    default="{ 'sobjectType': 'Camping_Item__c',
                         'Name': '',
                         'Price__c': 0,
                         'Quantity__c': 0,                         
                         'Packed__c': false
                       }"/>
    <ui:inputText value="{!v.newItem.Name}" aura:id="name" label="name"/>
    <ui:inputCheckbox value="{!v.newItem.Packed__c}" aura:id="Packed" label="Packed"/>
    <ui:inputCurrency value="{!v.newItem.Price__c}"  aura:id="Price" label="Price"/>
    <ui:inputNumber value="{!v.newItem.Quantity__c}" aura:id="Quantity" label="Quantity"/>
    <ui:button label="Create Expense" press="{!c.CreateCamping}" aura:id="button"/>
    <br/>
	<aura:iteration items="{!v.items}" var="PerItem">
        
        <c:campingListItem item="{!PerItem}" />
    </aura:iteration>
</aura:component>
CampingList.js
({
	
    doInit  : function(component, event, helper) {
		var action = component.get("c.getItems");
        action.setCallback(this, function(response){
            var state = response.getState();
           
            if (component.isValid() && state === "SUCCESS") {
           
               
                component.set("v.items", response.getReturnValue());
                 
            }
        });
        
        $A.enqueueAction(action);
	},
    
    CreateCamping : function(component, event, helper){
        
        helper.validateFields (component,component.find("name"));
        helper.validateFields (component,component.find("Price"));
        helper.validateFields (component,component.find("Quantity"));
        if(component.get("v.er") === false)
        {
            var lstItems = component.get("v.items");
            var Item = component.get("v.newItem");
            console.log('Before:'+lstItems);
            lstItems.push(Item);
            helper.CreateCampaign(component,Item);
            component.set("v.items",lstItems);  
             console.log('After:'+lstItems);
            component.set("v.newItem",{ 'sobjectType': 'Camping_Item__c',
                'Name': '',
                'Quantity__c': 0,
                'Price__c': 0,
                'Packed__c': false });
           
        }
	}
    
    
})

CampingListHelper.js
({
	
    validateFields : function (component,field) {
        
        var nameField = field;
        console.log('yes:'+nameField);
        var expname = nameField.get("v.value"); 
        if ($A.util.isEmpty(expname)){
           component.set("v.er",true);
           nameField.set("v.errors", [{message:"this field can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
    },
    
    CreateCampaign : function (component,Item){         
        var action = component.get("c.saveItem");
        action.setParams({"CampingItem":Item});
        action.setCallback(this,function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                console.log('save');
            }
        });
       $A.enqueueAction(action);        
    }
})
campingListItem.cmp
 
<aura:component >
    
   
    <aura:attribute type="Camping_Item__c" name="item" required="true"/>
    Name:
    <ui:outputText value="{!v.item.Name}" /><br/>
    Packed:
    <ui:outputCheckbox value="{!v.item.Packed__c}" /><br/>
    Price:
    <ui:outputCurrency value="{!v.item.Price__c}" /><br/>
   
    Quantity:
     <ui:outputNumber value="{!v.item.Quantity__c}" /><br/>
    
    <ui:button label="Packed!"  press="{!c.packItem}" aura:id = "Button"/> <br/>
</aura:component>

campingListItem.js
({
	    
    packItem : function(component, event, helper) {
		var pack = component.get("v.item");
        pack.Packed__c = true;
        component.set("v.item",pack);
        var btnClicked = event.getSource();
        btnClicked.set("v.disabled",true);
        
	}
    
    
})


Help me out with it.

Thanks and Regards,
Sai Krishna Tavva.


 
Hi everyone,
Can we Hide and Display the Custom fields in the Custom Object when a particular value in the picklist is selected.
Thanks in advance.
Regards,
Bhargav.
The campingList JavaScript controller isn't setting the 'item' as a parameter or saving the record correctly.

My code is as follows:

1---Camping List Component
<aura:component controller="CampingListController">
	
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    
    <aura:handler name="addItem" event="c:addItemEvent"
   	action="{!c.handleAddItem }"/>
    
    <aura:attribute name="newItem" type="Camping_Item__c"
     default="{ 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Quantity__c': 0,
                    'Price__c': 0,
                    'Packed__c': false }"/>
    
    <aura:attribute name="items" type="Camping_Item__c[]"/>
    
    <ol>
    <li>Bug Spray</li>
    <li>Bear Repellant</li>
    <li>Goat Food</li>
    </ol>
    
       <!-- NEW EXPENSE FORM -->
    <div class="slds-col slds-col--padded slds-p-top--large">

        <c:campingListForm/>

    </div>
    <!-- / NEW EXPENSE FORM -->    
   

    <div class="slds-card slds-p-top--medium">
        <header class="slds-card__header">
            <h3 class="slds-text-heading--small">Items</h3>
        </header>
        
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="items">
                    <c:campingListItem item="{!item}"/>
                </aura:iteration>
            </div>
        </section>
    </div>

</aura:component>

2---Camping List Controller
 
({
    // Load items from Salesforce
	doInit: function(component, event, helper) {

    // Create the action
    var action = component.get("c.getItems");

    // Add callback behavior for when response is received
    action.setCallback(this, function(response) {
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            component.set("v.items", response.getReturnValue());
        }
        else {
            console.log("Failed with state: " + state);
        }
    });

    // Send action off to be executed
    $A.enqueueAction(action);
},

    
    handleAddItem: function(component, event, helper) {
    var newItem = event.getParam("item");
    //helper.createItem(component, newItem);
        this.saveItem(component, item, function(response){
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            var items = component.get("v.items");
            items.push(response.getReturnValue());
            component.set("v.items", items);
        }
    }
          
}
                      
})

3---Camping List Helper

Empty

4---Camping List Form
 
<aura:component >
	
    <aura:registerEvent name="addItem" type="c:addItemEvent"/>
        <!-- CREATE NEW ITEM FORM -->
    <form class="slds-form--stacked">

      <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="itemname" label="Name"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Name}"
                  required="true"/>

          </div>
     </div>

     <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputNumber aura:id="quantity" label="Quantity"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Quantity__c}"
                  required="true"/>

          </div>
      </div>

      <div class="slds-form-element">
          <div class="slds-form-element__control">
              <ui:inputCurrency aura:id="price" label="Price"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Price__c}"
                  />
          </div>
      </div>

      <div class="slds-form-element">
          <ui:inputCheckbox aura:id="packed" label="Packed?"
              class="slds-checkbox"
              labelClass="slds-form-element__label"
              value="{!v.newItem.Packed__c}"/>
      </div>

      <div class="slds-form-element">
          <ui:button label="Create Camping Item"
              class="slds-button slds-button--brand"
              press="{!c.clickCreateItem}"/>
      </div>

    </form>
    <!-- / CREATE NEW ITEM FORM -->
</aura:component>

5---CampingListFormController
 
({
    
    clickCreateItem: function(component, event, helper) {    
    if(helper.validateItemForm(component)){
        // Create the new item
        var newItem = component.get("v.newItem");
        helper.createItem(component, newItem);
    }
        
        }

})

6---CampingListFormHelper
 
({
 createItem: function(component, newItem) {
    var createItem = component.getItem("createItem");
    createItem.setParams({ "item": item });
    createItem.fire();
             component.set("v.newItem",{ 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Quantity__c': 0,
                    'Price__c': 0,
                    'Packed__c': false }/>);
},
    

		validateItemForm: function(component) {
		
              // Simplistic error checking
        var validItem = true;

        // Name must not be blank
        var nameField = component.find("itemname");
        var itemname = nameField.get("v.value");
        if ($A.util.isEmpty(itemname)){
            validItem = false;
            nameField.set("v.errors", [{message:"Item name can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
        
        // Quantity must not be blank
        var quantityField = component.find("quantity");
        var quantity = nameField.get("v.value");
        if ($A.util.isEmpty(quantity)){
            validItem = false;
            quantityField.set("v.errors", [{message:"Quantity can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }
		// Price must not be blank
        var priceField = component.find("price");
        var price = priceField.get("v.value");
        if ($A.util.isEmpty(price)){
            validItem = false;
            priceField.set("v.errors", [{message:"Price can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }
            return validItem;

	}
})

I am still getting this error:

User-added image

Any help would be appreciated.
 
I have two lists(mainGroupLinkerIPGlist and toCopy) i am trying to remove all the values of mainGroupLinkerIPGlist from toCopy by creating a set and adding both the lists to the IPGset. below is the apex code.
 
List<Intralinks_Group_and_Contact_Links__c> mainGroupLinkerIPGlist = [SELECT Id,Intralinks_Portal_Group__c FROM Intralinks_Group_and_Contact_Links__c where Contact__c = :mainGroupLinker.Contact__c];
        //system.debug('mainGroupLinkerIPGlist =' + mainGroupLinkerIPGlist.size());

    //query all the Groups the copyFrom contact has
    if(copyFrom.Contact__c != null) {
       List<Intralinks_Group_and_Contact_Links__c> toCopy = [SELECT Id,Intralinks_Portal_Group__c FROM Intralinks_Group_and_Contact_Links__c where Contact__c = :copyFrom.Contact__c];

         system.debug('toCopy =' + toCopy.size());

         set<Intralinks_Group_and_Contact_Links__c> IPGset = New set<Intralinks_Group_and_Contact_Links__c>(toCopy);

         boolean result = IPGset.removeall(mainGroupLinkerIPGlist);
         System.assertEquals(true, result);
         system.debug('mainGroupLinkerIPGlist Count=' + mainGroupLinkerIPGlist.size());
         system.debug('IPGset count=' + IPGset.size());

when i am trying to remove all the mainGroupLinkerIPGlist values from set it is not removing and i am getting below message. System.AssertException: Assertion Failed: Expected: true, Actual: false
Hi,

I'm using a new DE for this badge but I have the error code b when I check the "Create sales dashboards in Salesforce Classic" challenge.

The complete arror message below :
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: MQOVJUPM

Can you help me ?

In advance, thank you !

Ben
Hey guys,

Need some help, I have a apex class with soql query on Reports of type (Task & Events) in the UAT, the reports for now returns 0 records as I have some filters as Date = Last 30 Days, I'm not able to cover the query line in test class as the report result 0 count, if the same report result atleat 1 record the query line are covered in the test class. Rest all the code lines are covered except these query lines.

Also a question, while moving the code from sandbox to production through change set will the test class validate against production org data or sandbox.

Thanks in advance,
Jancy Mary
Could anybody let me know the Differnce between salesforce record URLand Service console record URL. And how can we get the service console record URL dynamically to use in formula filed and that URL should work in production as well.

Any Suggestion welcome.
Thanks In Advance.
Hi,

1. We have created a lightning component and lightning application.
2. Referred lightning app in visualforce page to display the table of records.

When we are displaying the bulk records (more than 500), it is taking more time (>30 Sec)  due to huge logic in the javaScript helper.

Instead of displaying all the 500 records at a time which is consuming more time, I want to load 5 records first later it can process for the remaining records.

If anyone of you having suggestions please let me know.

Thanks,
Srinivas
 
Hi Team,

I need help in auto scroll in visualforce page. Actually i have tried like this http://jsfiddle.net/e8oxc71r/2/. But it didn't work properly.

<apex:page >
      <apex:form >
          <div id="box" class="timeline container" style="overflow:scroll; width:100%; height:300px;">
          Bacon ipsum dolor amet flank sausage salami, ball tip tail shoulder capicola pork loin chicken bacon cupim chuck andouille filet mignon. Frankfurter tongue doner boudin swine tenderloin, ground round leberkas hamburger beef strip steak cow jowl. Fatback salami tri-tip, pastrami cow short loin strip steak jerky. Jerky pancetta ribeye ball tip drumstick capicola bresaola boudin sirloin shank swine ham hock turducken. Strip steak pork chop turkey meatball pancetta pork shankle sirloin meatloaf pork loin cupim biltong. Picanha t-bone ham beef ribs, salami short loin pork jowl tongue ham hock boudin. Shoulder cupim shankle short ribs, bresaola capicola sirloin. Hamburger turkey turducken strip steak brisket kielbasa chicken pig ham hock. Pork salami doner short ribs landjaeger brisket capicola sausage pastrami corned beef tenderloin. Corned beef kevin bresaola pork tongue. Strip steak ribeye tenderloin leberkas brisket tongue hamburger cow andouille salami flank. Tenderloin pig kielbasa shoulder, pork corned beef bresaola chuck fatback. Doner tail meatball meatloaf corned beef. Sausage t-bone biltong chuck drumstick tail tenderloin cow. Hamburger alcatra strip steak jerky ham turducken drumstick meatball venison ball tip ribeye pastrami picanha jowl. Short ribs chuck filet mignon ham hock short loin tongue jowl, ball tip pork loin turkey strip steak swine corned beef venison tail. Chicken tri-tip ribeye, turducken beef ribs pork belly rump sirloin. Tenderloin strip steak swine sirloin turducken tongue pork loin kevin beef frankfurter kielbasa filet mignon jerky t-bone spare ribs. Shoulder pork belly frankfurter shank prosciutto fatback pig ball tip rump jerky landjaeger ribeye t-bone tongue. Corned beef andouille chicken, kevin t-bone turducken ribeye short ribs biltong tongue tri-tip drumstick leberkas sirloin cupim. Turducken short ribs boudin, cupim kevin short loin corned beef shankle sirloin ham hock salami. Pork belly chuck corned beef, andouille tri-tip bacon capicola short ribs shoulder short loin frankfurter alcatra tail t-bone ball tip. Chicken jowl spare ribs strip steak, t-bone pancetta turducken cupim doner cow ball tip boudin ham fatback. Strip steak shankle ground round kevin, swine pastrami landjaeger alcatra. Andouille salami pork loin flank pork chop, biltong short loin chicken kielbasa turducken. Pork jowl kielbasa tail. Turkey flank shank, rump venison meatloaf swine short ribs porchetta sausage. Chuck tongue corned beef chicken short ribs. Meatball flank alcatra, kielbasa jowl cow meatloaf corned beef shankle turducken brisket doner turkey. Turducken landjaeger boudin filet mignon fatback hamburger. Swine rump turducken ham hock, pork chop leberkas frankfurter short ribs fatback porchetta ground round.
          </div>
          
          

<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">
//<![CDATA[
$(window).on('load', function() {
// global level variables.
var isPaused = false;
var direction = 1;
var element = $('#box');

// interval for scroll.
setInterval(function () {
    if (!isPaused) {
        var pos = element.scrollTop();
        var offset = 1 * direction;
        element.scrollTop(pos + offset);

        // Change the scroll direction when hit an end.
        if ((element[0].scrollHeight - element.scrollTop() == element.outerHeight()) || (element.scrollTop() <= 0)) {
            direction *= -1;
        }
    }

}, 100);

$('#box').hover(

function () {
    isPaused = true;
}, function () {
    isPaused = false;
});
});//]]> 

</script>
         
      </apex:form>
</apex:page>

Please help me in this.

Thanks in advance.
Padmasree.

 
Hi I need to write test class for this please tell me how to write.It has reports and dashboards.
public class Embedded_Analytics_Extn{
    
    public Id AccPlanId{get; set;}
    public GE_HQ_Account_Plan__c aPlan{get;set;}
    public String DashId{get; set;}
    public String Report0Id{get; set;}
    public String Report0Name{get; set;}
    public String Report1Id{get; set;}
    public String Report1Name{get; set;}
    public String Report2Id{get; set;}
    public String Report2Name{get; set;}
    public String Report3Id{get; set;}
    public String Report3Name{get; set;}
    public String Report4Id{get; set;}
    public String Report4Name{get; set;}
    public String Report5Id{get; set;}
    public String Report5Name{get; set;}
    public String Report6Id{get; set;}
    public String Report6Name{get; set;}
    
    public String AccPlanName{get; set;}
    Public String DDUNS{get; set;}
    public List<SelectOption> tiers{get;set;}
    public String tier2{get;set;}
    public String tier3{get;set;}
    public String accName{get;set;}
    public Embedded_Analytics_Extn(ApexPages.StandardController controller){
        //Report r0=[select id,name,developerName from Report where developerName='TOTAL_CurrYr_IFRU'];
        //Report0Id=r0.id;
        //Report0Name=r0.name;
        Report r1=[select id,name,developerName from Report where developerName='OG_Tier_1_O_G_Region_Current_Year'];
        Report1Id=r1.id;
        Report1Name=r1.name;
        Report r2=[select id,name,developerName from Report where developerName='OG_Forecast_by_PL_Current_Year'];
        Report2Id=r2.id;
        Report2Name=r2.name;
        Report r3=[select id,name,developerName from Report where developerName='OG_Tier_2_Account_Region_Current_Year'];
        Report3Id=r3.id;
        Report3Name=r3.name;
        Report r4=[select id,name,developerName from Report where developerName='OG_SalesMgr_Current_Year_OPEN'];
        Report4Id=r4.id;
        Report4Name=r4.name;
        Report r5=[select id,name,developerName from Report where developerName='OG_Oppty_by_Stage_Current_Year'];
        Report5Id=r5.id;
        Report5Name=r5.name;
        Report r6=[select id,name,developerName from Report where developerName='OG_SalesMgr_Current_Year_Forecast'];
        Report6Id=r6.id;
        Report6Name=r6.name;
                
        DashId=[select id,developerName from Dashboard where developerName='OG_Account_Plan_Dashboard'].id;
        List<DashboardComponent> comp=[select id,name from DashboardComponent where DashboardId=:DashId];
        Map<String,DashboardComponent> DashCompMap=new Map<String,DashboardComponent>();
        for(DashboardComponent c: comp){
            DashCompMap.put(c.name,c);    
        }
        this.aPlan=(GE_HQ_Account_Plan__c)controller.getRecord();
        GE_HQ_Account_Plan__c AccPlan=[select id,name,GE_HQ_DDUNS_fm__c,GE_HQ_DDUNS_Number__c from GE_HQ_Account_Plan__c where id=:aPlan.Id];
        
        AccPlanName=AccPlan.Name;
        DDUNS=AccPlan.GE_HQ_DDUNS_fm__c;
        Account acc=[select id,name from Account where id=:AccPlan.GE_HQ_DDUNS_Number__c];
        this.accName=acc.name;
        /*
        tiers=new List<SelectOption>();
        tiers.add(new SelectOption('','None'));
        tiers.add(new SelectOption('Turbo Machinery','Turbo Machinery'));
        tiers.add(new SelectOption('PII Pipeline Solutions','Pipeline Solutions'));
        tiers.add(new SelectOption('Global Services (GS)','Global Services'));
        tiers.add(new SelectOption('Mesurement & Control (M&C)','Mesurement & Control'));
        tiers.add(new SelectOption('Drilling & Surface (D&S)','Drilling & Surface'));
        tiers.add(new SelectOption('Subsea (SS)','Subsea'));
        */
    }
    
    public PageReference setTiers(){
        this.tier2=aPlan.GE_OG_Tier_2_P_L__c;
        this.tier3=aPlan.GE_OG_Tier_3_P_L__c;
        return null;
    }
    
}

Posting this in order to help others who, months from now, might Google "OP_WITH_INVALID_USER_TYPE_EXCEPTION" and find this explanation.

 

We wrote an Apex trigger on the User object, to insert a custom object record anytime a user updates their Chatter status.  This was done to fulfill a client's requirement to audit all Chatter activity.

 

The trigger worked fine, until one day the client signed up some Chatter Free users.  When such a user tried to update their status, they got a pop-up with an OP_WITH_INVALID_USER_TYPE_EXCEPTION error.

 

We scratched our collective heads for awhile.  After all, Apex triggers run in "system mode," right?  That is supposed to mean that "object and field-level permissions of the current user are ignored."  And yet this trigger seemed like it was running in "user mode," enforcing restrictions based on who the current user was.

 

The root cause turned out to be that a Chatter Free user cannot be the owner of a custom object record, and SFDC by default sets the current user as a new record's first owner.  We discovered this when we realized, via experiment, that Apex triggers fired as the result of actions by Chatter Free users could definitely update an existing record, but were having problems creating records.

 

So the simple solution was to explicitly set the owner of the new record to some fully-licensed user prior to inserting it.