0
Changing Client's Name in Smart Projects after creation using Macros
Hello , I am trying to change the client name after creating the smart project but it only changes from the outside not from the inside of the project dashboard
is there anyway I can change it in both places ? I tried to setNameInternal and it didnt work aswell
here is my code
import com.radzisz.xtrf.utils.velocity.VelocityTagUtils import com.radzisz.xtrf.model.project.Project import com.radzisz.xtrf.service.CustomerService import com.radzisz.xtrf.model.partner.customer.Customer class ChangeClient { def list; def params; VelocityTagUtils utils = new VelocityTagUtils(); ChangeClient(list, params){ this.list = list; this.params = params; } CustomerService customers = utils.getService("com.radzisz.xtrf.service.CustomerService") Customer newCustomer = customers.getByName("DTest2") def nameOfNewCustomer = newCustomer.getName() def runMacro() { String customerName list.each{Project project -> project.setCustomerInternal(newCustomer) project.getCustomer().setNameInternal(nameOfNewCustomer) } } } new ChangeClient(list, params).runMacro();
Customer support service by UserEcho
You are trying to update the customer itself (I don't think that's something you want). And you are trying to update the internal name. Which is not the right one. You are looking for setName() and setFullname()
Also, don't forget to check the box Macro Modifies Model Data, which is neccesary to change the data in the database.
This piece of code will update the customer's name, you can change the newName variable:
Thank you for replying so quickly, I really appreciate it. I actually want to change the customer itself to another not just the name of it. that's why I am using setCustomerInternal however i can't get it to work as i want it to.. not sure what I am doing wrong there. I want to run the macro on a project and it changes the client completely to a different client i'll be setting in the code. Is my code the right approach to achieve that ?
Thank you very much in advance.
I don't think you can. XTRF is very explicit regarding changing the client after quote/project creation: this isn't possible.