You need to sign in to do that
Don't have an account?
azar khasim
Need to update the Owner and account name in a record while saving in Custom Object.
Hi All,
I have a Booking Link(Custom Object) and Account Object. There is a relation between both of them using Lookup. and i had a field called Customer Number in Accounts.
By using Sites i am storing a record which contains Customer number as one of the field in that record in BookingLink Object.
Now By using this Customer Number i need to update the Account Name and Owner of that Customer Number(Which already had a record in Account object).
Please help me out from thiss.
""When ever a Record is created in BookingLink Object, by using Customer Number it need to update the Account name and Owner of the record"".
Thanks and Regards,
Azar Khasim.
I have a Booking Link(Custom Object) and Account Object. There is a relation between both of them using Lookup. and i had a field called Customer Number in Accounts.
By using Sites i am storing a record which contains Customer number as one of the field in that record in BookingLink Object.
Now By using this Customer Number i need to update the Account Name and Owner of that Customer Number(Which already had a record in Account object).
Please help me out from thiss.
""When ever a Record is created in BookingLink Object, by using Customer Number it need to update the Account name and Owner of the record"".
Thanks and Regards,
Azar Khasim.
if we want to update account name and owner on Billing Link (Custom Object)
I hope above code will be helpful.
All Answers
if we want to update account name and owner on Billing Link (Custom Object)
I hope above code will be helpful.
Thanks for the code, But its not working from my side.
Can u please help me from this..,
We have ''Person Contact'' Object means( Account+Contact )Object, Where this
Customer Number has been there like
API Name : Customer_Number__pc.
We Have BookingLink API as : Booking_Link__c
In Booking Link we have the same Customer Number field as : Customer_Number__c
Now,
""When ever a Record is created in BookingLink Object, by using Customer Number, it need to update the Account name and Owner of the record"".
I am Using Sites to create the record in BookingLink.
Already we have a record in PersonAccount( Account+Contact )Object now
the new record in Booking Link need to check Customer Number in Person Account and Update the Account and Owner Names in Booking Link Record which we created.
Below is my Trigger:
Trigger Account Update on Booking Link Custom Object.
************************************************************************************************
trigger AccountUpdate on Booking_Link__c (after insert) {
Map<ID, Account> parent = new Map<ID, Account>();
List<Id> listIds = new List<Id>();
for (Booking_Link__c blink : Trigger.new) {
listIds.add(blink.Account__c); // API name of parent field in child object
}
parent = new Map<Id, Account>([SELECT Id, Name, Customer_Number__pc, (SELECT Id, Customer_Number__c FROM Booking_Link__r)
FROM Account
WHERE ID IN :listIds]); // see Child Relationship Name
for (Booking_Link__c bk: Trigger.new){
if(bk.Customer_Number__c!=null){
Account acc = parent.get(bk.Account__c);
acc.Name = bk.Name;
acc.OwnerId = bk.OwnerId;
}
}
UPDATE parent.values();
******************************************************************************************************
Please help me out
This trigger is not allowing the record to get saved into Booking Link Custom Object through Sites which i am using it.
The trigger is stopping to get saved in object.
Please help me out from this issue.
Thanks and Regards,
Azar Khasim.
See you have to set value of account name and onwer while creating of the record in Billing Link object.
So first thing is you have to use before event trigger.
Secong thing while creating record of billing link , How can u get account id withount hving value of account field in billing object.
please check my code again beacause its working in my org perfectly.
I hope you understand the issue.
I have a relation between BookingLink and Account.
I have a account field in BookingLink Object.
It was working manually when i copy paste the Account name in Booking link account filed it was updating the owner name.
But i want that process to get automate by using Trigger.
whenever record is created in BookingLink, then it need to check for CustomerNumber in Account object,
then it need to update the Account name and Owner in Booking Link Object.
Hope you got my requirement in detail.
So please help me to resolve the issue which i have!!!!
Thanks and Regards,
Azar Khasim.
See the following code:
i have an account record which having customer number .
See in bellow image account name is Sara and Customer Number is 2
Now i will go to billing Link object and will create a record
See in bellow image: I have not filled account field value
Now i will click on save
and the result you see in next bellow image:
Account Name is updated as Sara and owner is me bcz i was owner of sara also
and customer number is 2
I hope this is only your requirments.
Yes, what you have shown is helpful and its working, Thank you,
But, I am Using this code i am facing some errors can u please help me in this.
Line 6: CustomNumber = bl.Customer_Number__c;
Line 8: accountList = [Select Id, OwnerId, Customer_Number__pc from Account where Customer_Number__c =:CustomNumber ];
In Line 8 i have changed the bold one from Customer_Number__c to Customer_Number__pc.
why because we have the Customer Number field API as above because we are using PersonAccount.
Please help me from these errors.
Errors:
Line 6: Illegal assignment from String to Decimal
Line 8:
Customer_Number__pc from Account where Customer_Number__c =:CustomNumber
^
ERROR at Row:1:Column:60
No such column 'Customer_Number__c' 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.
Thanks and Regards,
Azar Khasim.
Line 8: accountList = [Select Id, OwnerId, Customer_Number__pc from Account where Customer_Number__c =:CustomNumber ];
In Line number 8 : in the query after where clause use same API name as Customer_Number__pc, So qrery will be like this:
[Select Id, OwnerId, Customer_Number__pc from Account where Customer_Number__pc =:CustomNumber ];
Line 6: CustomNumber = bl.Customer_Number__c;
So in line number 6 may be data type of your Custome Number field in Billing link is Text u have teken and you are assigning to Decimal CustomNumber
So so do one thing either you change data type of Customer_Number__c or you can change data type in code of CustomNumber variable
your error will go.
I hope this information will be helpful.
Yes, I solved it at that time only, and thanks for the steps, i have done the same for it before.
But, as u have shown me using the front end part like giving customer number directly in booking link object and autopopulating the names.
But i am using Sites to save a record in Booking Link Object, so while using this Trigger as Active, I am unable to save the record into Booking Link from the Sites.
The Trigger itself not allowing to save the record.
When i Inactive the trigger.
The record is getting saved.
Please help me from this issue.
Thanks and Regards,
Azar Khasim.