Skip to content

Commit 9ef1e22

Browse files
authored
Merge pull request #835 from OpenSignLabs/fix_linkcontact
2 parents 4d7348a + 655401e commit 9ef1e22

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

apps/OpenSignServer/cloud/parsefunction/linkContactToDoc.js

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,16 @@ export default async function linkContactToDoc(req) {
8181
const updateDoc = new Parse.Object('contracts_Document');
8282
updateDoc.id = docId;
8383
const signers = _docRes?.Signers || [];
84-
signers.push({
84+
const signerobj = {
8585
__type: 'Pointer',
8686
className: 'contracts_Contactbook',
8787
objectId: existContact.id,
88-
});
88+
};
89+
// The splice method is used to add a signer at the desired index
90+
// index is the variable where the signer needs to be added
91+
// 0 indicates that no elements should be deleted
92+
// signerobj is the reference to the signer object
93+
signers.splice(index, 0, signerobj);
8994
updateDoc.set('Signers', signers);
9095

9196
Placeholders[index] = {
@@ -128,11 +133,16 @@ export default async function linkContactToDoc(req) {
128133
const updateDoc = new Parse.Object('contracts_Document');
129134
updateDoc.id = docId;
130135
const signers = _docRes?.Signers || [];
131-
signers.push({
136+
const signerobj = {
132137
__type: 'Pointer',
133138
className: 'contracts_Contactbook',
134139
objectId: contactRes.id,
135-
});
140+
};
141+
// The splice method is used to add a signer at the desired index
142+
// index is the variable where the signer needs to be added
143+
// 0 indicates that no elements should be deleted
144+
// signerobj is the reference to the signer object
145+
signers.splice(index, 0, signerobj);
136146
updateDoc.set('Signers', signers);
137147

138148
Placeholders[index] = {
@@ -175,11 +185,16 @@ export default async function linkContactToDoc(req) {
175185
const updateDoc = new Parse.Object('contracts_Document');
176186
updateDoc.id = docId;
177187
const signers = _docRes?.Signers || [];
178-
signers.push({
188+
const signerobj = {
179189
__type: 'Pointer',
180190
className: 'contracts_Contactbook',
181191
objectId: contactRes.id,
182-
});
192+
};
193+
// The splice method is used to add a signer at the desired index
194+
// index is the variable where the signer needs to be added
195+
// 0 indicates that no elements should be deleted
196+
// signerobj is the reference to the signer object
197+
signers.splice(index, 0, signerobj);
183198
updateDoc.set('Signers', signers);
184199

185200
Placeholders[index] = {
@@ -227,13 +242,17 @@ export default async function linkContactToDoc(req) {
227242
const updateDoc = new Parse.Object('contracts_Document');
228243
updateDoc.id = docId;
229244
const signers = _docRes?.Signers || [];
230-
signers.push({
245+
const signerobj = {
231246
__type: 'Pointer',
232247
className: 'contracts_Contactbook',
233248
objectId: contactRes.id,
234-
});
249+
};
250+
// The splice method is used to add a signer at the desired index
251+
// index is the variable where the signer needs to be added
252+
// 0 indicates that no elements should be deleted
253+
// signerobj is the reference to the signer object
254+
signers.splice(index, 0, signerobj);
235255
updateDoc.set('Signers', signers);
236-
237256
Placeholders[index] = {
238257
...Placeholders[index],
239258
signerObjId: contactRes.id,

0 commit comments

Comments
 (0)