+=item get_remoteid SVC
+
+Returns the remote id for this export for the given service.
+
+=cut
+
+sub get_remoteid {
+ my ($self, $svc_x) = @_;
+
+ my $export_cust_svc = qsearchs('export_cust_svc',{
+ 'exportnum' => $self->exportnum,
+ 'svcnum' => $svc_x->svcnum
+ });
+
+ return $export_cust_svc ? $export_cust_svc->remoteid : '';
+}
+
+=item set_remoteid SVC VALUE
+
+Sets the remote id for this export for the given service.
+See L<FS::export_cust_svc>.
+
+If value is true, inserts or updates export_cust_svc record.
+If value is false, deletes any existing record.
+
+Returns error message, blank on success.
+
+=cut
+
+sub set_remoteid {
+ my ($self, $svc_x, $value) = @_;
+
+ my $export_cust_svc = qsearchs('export_cust_svc',{
+ 'exportnum' => $self->exportnum,
+ 'svcnum' => $svc_x->svcnum
+ });
+
+ local $SIG{HUP} = 'IGNORE';
+ local $SIG{INT} = 'IGNORE';
+ local $SIG{QUIT} = 'IGNORE';
+ local $SIG{TERM} = 'IGNORE';
+ local $SIG{TSTP} = 'IGNORE';
+ local $SIG{PIPE} = 'IGNORE';
+
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ my $dbh = dbh;
+
+ my $error = '';
+ if ($value) {
+ if ($export_cust_svc) {
+ $export_cust_svc->set('remoteid',$value);
+ $error = $export_cust_svc->replace;
+ } else {
+ $export_cust_svc = new FS::export_cust_svc {
+ 'exportnum' => $self->exportnum,
+ 'svcnum' => $svc_x->svcnum,
+ 'remoteid' => $value
+ };
+ $error = $export_cust_svc->insert;
+ }
+ } else {
+ if ($export_cust_svc) {
+ $error = $export_cust_svc->delete;
+ } #otherwise, it already doesn't exist
+ }
+
+ if ($oldAutoCommit) {
+ $dbh->rollback if $error;
+ $dbh->commit unless $error;
+ }
+
+ return $error;
+}
+