You need to sign in to do that
Don't have an account?
Keer Yenduri
public class MyHelloWorld { public static void applyDiscount(Boook__c[] books) { for(Boook__c b:books) b.Prise__c*=0.9; } }
Hi,
public class MyHelloWorld
{
public static void applyDiscount(Boook__c[] books)
{
for(Boook__c b:books)
b.Prise__c*=0.9;
}
}
when i am trying to executive this class it's getting error,plz urgent.
Thanks!!
public class MyHelloWorld
{
public static void applyDiscount(Boook__c[] books)
{
for(Boook__c b:books)
b.Prise__c*=0.9;
}
}
when i am trying to executive this class it's getting error,plz urgent.
Thanks!!
I tried at my end with the below code and it is working fine. In Debug, you will get the prise value as 90.
If you still get the error try with firefox or Google Crome browser.
All Answers
What error you are getting?
First you should create a "Boook" object with "Prise__c" field in salesforce.
After that write a tigger on that object, only then it will work.
Check the below link for more informatiom.
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_qs_HelloWorld.htm
I created already and what my trigger is
trigger HelloWorldTrigger on Boook__c (before insert)
{
Boook__c[] books = Trigger.new;
MyHelloWorld.applyDiscount(books);
}
this trigger is right r wrong?
please let me know.
What error you are getting?
are you putting any value in "Prise__c" field before inserting the record?
Annop
that example is what u sent it to me i.e i am trying with the same example only,it's showing error when i am executing that class.
may be "boooks__c" i took array of custom object.
Thanks!!
And how you are Executing this class?
plz let me know.
And how you are Executing this class?
i am getting dis err
"
Method does not exist or incorrect signature: MyHelloWorld.applyDiscount()
"
MyHelloWorld.applyDiscount();
in developer consle.
and when you insert the boook record it will call that method.
If you want to execute from developer console Use the below code.
Long running operation did not complete, continuing in background
this type of error is comming.
or check by creating the tab.
i downloaded the log
i.e
32.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
23:35:00.031 (31928455)|EXECUTION_STARTED
23:35:00.031 (31977804)|CODE_UNIT_STARTED|[EXTERNAL]|VisualForce View State
23:35:00.040 (40676008)|CODE_UNIT_FINISHED|VisualForce View State
23:35:00.041 (41994745)|EXECUTION_FINISHED
23:35:01.310 (353857755)|CUMULATIVE_LIMIT_USAGE
23:35:01.310|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
23:35:01.310|CUMULATIVE_LIMIT_USAGE_END
and what result you are expecting?
Anoop first i want to execute the class den i will k with my class.
if it is executed den i will think that class is correct.
So i want to execute that class
see
first i created the custom object and custom fields for that
next i wrote trigger and class,
in my way of thinking if class works proprly den my work is done
Create a tab for the above object by SetUp==>Tabs
click on new in "Custom Object Tabs", select the object and save.
After that you will get a Boook tab in tab panel.
Click on the tab, create new record, enter the name and price
after saving the record price value will be multiplied by 0.9.
Let me know if you neeed more help.
Okay Anoop i created like that only and what i am saying is i want to execute class alone i want to check whther it is working r not
u gave code for developer console i tried with that after that i got the error
like"Long running operation did not complete, continuing in background"
is it error r is it work backend?
is it showing like?
and when created records for Boook__c object creating the records
and so is our job done without getting any error for record creation?
i want that.
Thanks!!!
Can you run that again and let me know.
or run the below code
Again i tried,
But
i got this error
ERROR:in developer console
expecting left curly bracket, found ';'
with this code when i am executing
Boook__c[] bookList = new Boook__c[];
Boook__c b = new Boook__c(Name = 'Test',Prise__c = 100);
bookList.add(b);
MyHelloWorld.applyDiscount(bookList);
And i am saying u
what are my components are:
1)
Objectname:Boook APIname:Boook__c
Fieldname:Prise APIname:Prise__c
2)
trigger HelloWorldTrigger on Boook__c (before insert)
{
Boook__c[] books = Trigger.new;
MyHelloWorld.applyDiscount(books);
}
3)
public class MyHelloWorld
{
public static void applyDiscount(Boook__c[] books)
{
for(Boook__c b:books)
{
b.Prise__c*=0.9;
}
}
}
4)
DeveloperConsole:
Boook__c[] bookList = new Boook__c[];
Boook__c b = new Boook__c(Name = 'Test',Prise__c = 100);
bookList.add(b);
MyHelloWorld.applyDiscount(bookList);
Please let me know the solution for that.
Thanks!!!!
I tried at my end with the below code and it is working fine. In Debug, you will get the prise value as 90.
If you still get the error try with firefox or Google Crome browser.
Thank u so much,it's working.
And may i know do u have hands on experience in webservices in salesforce?
why becoz now i am working in webservices so please let me know i have doubts.
If you post any issue, you will get help from other developers as well.
Thanks
Okay fine please let me know
i will tell a scenario:
i create one customer in salesfroce and updates also willbe there
regarding this i want to write a trigger
i don't know how to write a trigger for this scenarioo.
Please help me out how to write that trigger regarding that scenario.