Disable Use Credentials Of Login User. If this is disabled, the connection will utilize the credentials of the connection owner.
work_order_id = work_order.get("id"); Amount = 0; Service_Line_Items_List = work_order.get("Service_Line_Items").toList(); for each Service_Line_Items in Service_Line_Items_List { Service_Line_Items_Map = Service_Line_Items.toMap(); if(Service_Line_Items_Map.get("Service").toMap().get("name") == "Expense") { //Get Currency Id headers_data = Map(); headers_data.put("X-com-zoho-expense-organizationid","<orgId>"); response = invokeurl [ type :GET headers:headers_data connection:"zexpense" ]; currencyList = response.get("currencies").toList(); for each eachCurrencyList in currencyList { CurrencyMap = eachCurrencyList.toMap(); if(CurrencyMap.get("currency_code") == "USD") { currency_id = CurrencyMap.get("currency_id"); } } //Get Category Id headers_data_1 = Map(); headers_data_1.put("X-com-zoho-expense-organizationid","<orgId>"); response_1 = invokeurl [ type :GET headers:headers_data_1 connection:"zexpense" ]; expense_categories_list = response_1.get("expense_accounts").toList(); for each each_expense_categories_list in expense_categories_list { expense_categories_map = each_expense_categories_list.toMap(); //Use the Expense Category - Travel Expense if(expense_categories_map.get("category_name") == "Travel Expense") { category_id = expense_categories_map.get("category_id"); } } Amount = Amount + Service_Line_Items_Map.get("Line_Item_Amount"); Created_Time = Service_Line_Items_Map.get("Created_Time").toString(); Create_Date = Created_Time.getPrefix("T"); lineItemList = list(); lineItemMap = Map(); lineItemMap.put("category_id",category_id); lineItemMap.put("amount",Amount); lineItemMap.put("description","From Zoho FSM"); lineItemList.add(lineItemMap); createMap = Map(); createMap.put("currency_id",currency_id); createMap.put("date",Create_Date); createMap.put("is_reimbursable",true); createMap.put("line_items",lineItemList); headers_data_2 = Map(); headers_data_2.put("X-com-zoho-expense-organizationid","<orgId>"); response_2 = invokeurl [ type :POST parameters:createMap.toString() headers:headers_data_2 connection:"zexpense" content-type:"application/json" ]; expense_id = response_2.get("expenses").toMap().get("expense_id").toString(); updateResp = zoho.fsm.updateRecord("Work_Orders",work_order_id,{"<custom_field_Api_name>":expense_id}); } } |