1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update blue print |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | module_api_name: string, |
12 | record_id: string, |
13 | body: { |
14 | blueprint: { |
15 | transition_id: string; |
16 | data: { |
17 | id?: string; |
18 | Created_By?: { name: string; id: string; email?: string }; |
19 | Created_Time?: string; |
20 | Modified_By?: { name: string; id: string; email?: string }; |
21 | Modified_Time?: string; |
22 | Tag?: { |
23 | name: string; |
24 | color_code: |
25 | | "#57B1FD" |
26 | | "#879BFC" |
27 | | "#658BA8" |
28 | | "#FD87BD" |
29 | | "#969696" |
30 | | "#F48435" |
31 | | "#1DB9B4" |
32 | | "#E7A826" |
33 | | "#63C57E" |
34 | | "#F17574" |
35 | | "#D297EE" |
36 | | "#A8C026" |
37 | | "#B88562"; |
38 | created_time: string; |
39 | modified_time: string; |
40 | modified_by: { name: string; id: string; email?: string }; |
41 | created_by: { name: string; id: string; email?: string }; |
42 | id: string; |
43 | }[]; |
44 | name?: string; |
45 | }; |
46 | process_info: { |
47 | field_id: number; |
48 | is_continuous: false | true; |
49 | api_name: string; |
50 | continuous: false | true; |
51 | field_label: string; |
52 | name: string; |
53 | column_name: string; |
54 | field_value: string; |
55 | id: string; |
56 | field_name: string; |
57 | escalation?: { days?: number; status?: string }; |
58 | current_picklist?: { |
59 | colour_code?: string; |
60 | id?: string; |
61 | value?: string; |
62 | }; |
63 | }; |
64 | transitions: { |
65 | type?: string; |
66 | execution_time?: string; |
67 | sequence?: number; |
68 | next_transitions: { |
69 | id: string; |
70 | name: string; |
71 | criteria_matched?: false | true; |
72 | type?: string; |
73 | }[]; |
74 | parent_transition?: {}; |
75 | percent_partial_save: number; |
76 | data: { |
77 | id?: string; |
78 | Created_By?: { name: string; id: string; email?: string }; |
79 | Created_Time?: string; |
80 | Modified_By?: { name: string; id: string; email?: string }; |
81 | Modified_Time?: string; |
82 | Tag?: { |
83 | name: string; |
84 | color_code: |
85 | | "#57B1FD" |
86 | | "#879BFC" |
87 | | "#658BA8" |
88 | | "#FD87BD" |
89 | | "#969696" |
90 | | "#F48435" |
91 | | "#1DB9B4" |
92 | | "#E7A826" |
93 | | "#63C57E" |
94 | | "#F17574" |
95 | | "#D297EE" |
96 | | "#A8C026" |
97 | | "#B88562"; |
98 | created_time: string; |
99 | modified_time: string; |
100 | modified_by: { name: string; id: string; email?: string }; |
101 | created_by: { name: string; id: string; email?: string }; |
102 | id: string; |
103 | }[]; |
104 | name?: string; |
105 | }; |
106 | next_field_value: string; |
107 | text_color_code: string; |
108 | name: string; |
109 | criteria_matched: false | true; |
110 | id: number; |
111 | fields: { |
112 | external?: { |
113 | show: false | true; |
114 | type: string; |
115 | allow_multiple_config?: false | true; |
116 | }; |
117 | display_type?: -1 | 2; |
118 | filterable?: false | true; |
119 | pick_list_values_sorted_lexically?: false | true; |
120 | sortable?: false | true; |
121 | ui_type?: number; |
122 | private?: { |
123 | restricted: false | true; |
124 | type: string; |
125 | export: false | true; |
126 | }; |
127 | system_mandatory: false | true; |
128 | webhook: false | true; |
129 | json_type: string; |
130 | crypt: { |
131 | mode: string; |
132 | column: string; |
133 | table: string; |
134 | status: number; |
135 | }; |
136 | field_label: string; |
137 | tooltip: { name: string; value: string }; |
138 | created_source: string; |
139 | layouts: { id: string; name: string }; |
140 | field_read_only: false | true; |
141 | content: string; |
142 | display_label: string; |
143 | validation_rule: string; |
144 | read_only: false | true; |
145 | association_details: { |
146 | lookup_field: { id: string; name: string }; |
147 | related_field: { id: string; name: string }; |
148 | }; |
149 | multi_module_lookup: { |
150 | display_label: string; |
151 | api_name: string; |
152 | modules: { |
153 | api_name: string; |
154 | id: string; |
155 | module_name?: string; |
156 | module?: string; |
157 | }[]; |
158 | }; |
159 | currency: { rounding_option: string; precision: number }; |
160 | id: string; |
161 | custom_field: false | true; |
162 | lookup: { |
163 | display_label: string; |
164 | api_name: string; |
165 | module: string; |
166 | id: string; |
167 | }; |
168 | convert_mapping: {}; |
169 | visible: false | true; |
170 | length: number; |
171 | column_name: string; |
172 | _type: string; |
173 | view_type: { |
174 | view: false | true; |
175 | edit: false | true; |
176 | create: false | true; |
177 | quick_create: false | true; |
178 | }; |
179 | transition_sequence: number; |
180 | api_name: string; |
181 | unique: { casesensitive?: string }; |
182 | history_tracking: false | true; |
183 | data_type: string; |
184 | formula: { return_type: string; expression: number }; |
185 | decimal_place: string; |
186 | multiselectlookup: { |
187 | display_label: string; |
188 | linking_module: string; |
189 | lookup_apiname: string; |
190 | api_name: string; |
191 | connectedlookup_apiname: string; |
192 | id: string; |
193 | }; |
194 | pick_list_values: { |
195 | colour_code: string; |
196 | actual_value: string; |
197 | type: "unused" | "used"; |
198 | id: string; |
199 | sequence_number: number; |
200 | display_value: string; |
201 | reference_value?: string; |
202 | deal_category?: string; |
203 | probability?: number; |
204 | forecast_category?: { id?: string; name?: string }; |
205 | expected_data_type?: string; |
206 | sys_ref_name?: string; |
207 | forecast_type?: string; |
208 | maps?: { api_name?: string; pick_list_values?: {}[] }[]; |
209 | _delete?: false | true; |
210 | show_value?: false | true; |
211 | }[]; |
212 | auto_number: { prefix: string; suffix: string; start_number: number }; |
213 | personality_name: string; |
214 | mandatory: false | true; |
215 | quick_sequence_number: number; |
216 | profiles?: { id?: string; name?: string; permission_type?: string }[]; |
217 | }[]; |
218 | color_code: string; |
219 | criteria_message: string; |
220 | }[]; |
221 | }[]; |
222 | }, |
223 | ) { |
224 | const url = new URL( |
225 | `https://zohoapis.com/crm/v8/${module_api_name}/${record_id}/actions/blueprint`, |
226 | ); |
227 |
|
228 | const response = await fetch(url, { |
229 | method: "PUT", |
230 | headers: { |
231 | "Content-Type": "application/json", |
232 | Authorization: "Zoho-oauthtoken " + auth.token, |
233 | }, |
234 | body: JSON.stringify(body), |
235 | }); |
236 | if (!response.ok) { |
237 | const text = await response.text(); |
238 | throw new Error(`${response.status} ${text}`); |
239 | } |
240 | return await response.json(); |
241 | } |
242 |
|