I am planning of writing a plugin on the topic update, and retrieve the list of all the references where a particular topic is being used. Please help me with some guidance.
You need to be using the Content Manager web services API in Docs to be able to retrieve the references for a topic. The documentation of an example web service call is here.
The web service class you are looking for is the Reports class which contains the method
GetReferencesByIshLngRef. This method is synonymous with Where Used and will return where a specific topic is referenced.
So in your application, you would add a service reference to the Reports service. The URL would be the web service URL followed by
/Wcf/API20/reports.svc and for the namespace give something like
ReportsClientServiceReference. For example,
https://docs.sdldemo.com/ISHWS/Wcf/API20/reports.svc. Visual Studio would then generate the necessary classes and update the .config appropriately. You should be able to now call the method
The following example code should get the list of items referenced by a topic.
var ishWSUri = new Uri(@"https://docs.sdldemo.com/ISHWS/"); var ishWSBinding = new CustomBinding("CustomBinding_Application1"); var reportsUri = new Uri(ishWSUri, "Wcf/API20/Reports.svc"); var issuerUri = new Uri(@"https://docs.sdldemo.com/ISHSTS/issue/wstrust/mixed/username"); var credential = new NetworkCredential("<user name>", "<password>"); var authenticationType = enAuthenticationType.UsernameMixed; var token = IssueToken(issuerUri, authenticationType, credential, ishWSUri); var reportsClient = new ReportsClientServiceReference.ReportsClient(ishWSBinding, new EndpointAddress(reportsUri)); var reportsChannel = reportsClient.ChannelFactory.CreateChannelWithIssuedToken(token); ReportsClientServiceReference.GetReferencesByIshLngRefRequest inValue = new ReportsClientServiceReference.GetReferencesByIshLngRefRequest(); string xmlExtObjectList = "<ishfields>" + " <ishfield name='VERSION' level='version'/>" + " <ishfield name='DOC-LANGUAGE' level='lng'/>" + " <ishfield name='FTITLE' level='logical'/>" "</ishfields>"; // The ID of the topic at the language level. This can also be a comma-seperated list. inValue.lngRefs = "11689"; inValue.xmlExtObjectList = xmlExtObjectList; ReportsClientServiceReference.GetReferencesByIshLngRefResponse references = reports20Channel.GetReferencesByIshLngRef(inValue); String returnValue = references.returnValue; // xmlOutput contains all Docs objects referenced by a topic. String xmlOutput = references.xmlExtObjectList;